I found such a script. But it works on all open files and takes a lot of time. How do I do it to only one current tab.

var doc = activeDocument; 
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 ("PANTONE", "P.");
        app.documents[i].textFrames[j].contents = rep;
  • remove the for loops and run the commands on doc
    – joojaa
    Oct 12, 2022 at 16:08
  • For one doc.. why not just find and replace in AI itself? There is a "Replace All" button.
    – Scott
    Oct 12, 2022 at 17:10

1 Answer 1


@joojaa your answer is too short. I don't quite understand but I found my own answer by trial and error.

for(var j = 0; j < app.documents[0].textFrames.length; j++)
{ var str = app.documents[0].textFrames[j].contents;
         var rep = str.replace("PANTONE", "P.");
         app.documents[0].textFrames[j].contents = rep; }

Your Answer

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

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