I'm working on a project that has 1000 files with the same typo ex. the file with the word "dogs" that has to be turned into "dog". these 1000 files has the same typo. Is there anyway that I can write a script to do that in Illustrator? or some API that I can extract out text from the file then edit it (change from "dogs" into "dog") then save it back because I don't want to open 1000 files and do it 1000 times.

  • is word "dogs" is a text layer?
    – Mr.Online
    Apr 23, 2019 at 10:19
  • yes it is in a text layer but nested in other layer.
    – user136301
    Apr 23, 2019 at 10:25
  • This script doesn't do exactly what you want, but if you're willing to wrangle the script to do what you want, it's already like 90% there: forums.adobe.com/message/10364559#10364559 - You could perhaps make an Action where you run the script and then run it on all of your documents in batch. - Gotta say this is the first time I've seen a script with a "donate" dialog.
    – Joonas
    Apr 23, 2019 at 11:07

1 Answer 1


This script will find keyword "Dogs" and replace it with "Dog" within all open documents

    #target illustrator
    var count;
var folderRef = Folder.selectDialog ("choose Folder");
var prefix = prompt("Prefix name","");
var fileRef = folderRef + "/" + prefix;
for (count=0;count<9999;count++){
    var temp;
        temp = "000";
        }else if(count>=10 && count<100){
        temp = "00";
        }else if(count>=100 && count<1000){
        temp = "0";
            temp = "";
    var result = fileRef + " " + temp + count;
    var f = new File(result + ".ai");
    if ( f.exists ) {
        app.open( new File(f) );
for(var i = 0; i < app.documents.length; i++){    
    for(var j = 0; j < app.documents[i].textFrames.length; j++){    
        var str = app.documents[i].textFrames[j].contents;    
        var rep = str.replace ("Dogs", "Dog");
        app.documents[i].textFrames[j].contents = rep;
//justification lines
       var z = app.documents[i].textFrames[j].paragraphs[0].paragraphAttributes;
       z.justification = Justification.CENTER; 
app.activeDocument.close(SaveOptions.SAVECHANGES);   //comment this lineby putting "//" before it if you wanna keep your file open after edited


so if you want to replace word from all open document you can use this; save this code as ReplaceTest(orWhatever).jsx then put it in your script folder,and restart your Illustrator . you will find your script at File-Scripts.

enter image description here

Comment your requirement below for further improvements in code :) you can see how i achieved it; don't forget to comment close command if you wanna keep your file open

enter image description here

  • wow thank you so so much for your help Design Phoenix, I would like 2 more improvements, 1. I want it to report to me which document has been edited and which one are not since some file contents the word dog and some aren't I would like to get a list of file being edited. 2. can I specify the folder path and let it automate every file in that folder without me open 100 files manually? I'm using MacOS. thank you so much for your support
    – user136301
    Apr 23, 2019 at 11:32
  • if you have folder than can you tell me file pattern like test_1 test_2 etc?
    – Mr.Online
    Apr 23, 2019 at 11:33
  • Newyork 0244, Newyork 0245, Newyork 0246, Newyork 0247 California 2230, California 2231, California 2232 something like this. thank you so so much for your help.
    – user136301
    Apr 23, 2019 at 11:36
  • well will it be okay if you type Newyork once and it edit all your Newyork named files?
    – Mr.Online
    Apr 23, 2019 at 11:37
  • that would be great too.
    – user136301
    Apr 23, 2019 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.