7 Replies Latest reply on Dec 7, 2017 8:00 PM by OMOTI

    batch find & replace text in Illustrator files in a folder?

    susank90600475

      I found this script which work greats on any currently open Illustrator files, but I would like it to be able to run the action on a Mac OS folder, open the first Illustrator, runs this javascript, save & close that file, then loop through all other Illustrator files in a folder and repeat the process, until the last file.

       

      1. function FindAndReplaceScript_AllOpenDocuments(){     
      2.     for(var i=app.documents.length -1; i > -1;  i--){     
      3.         app.documents[i].activate(); 
      4.         var aDoc = app.documents[i]; 
      5.              
      6.         var searchString = /VT/gi;    
      7.         var replaceString = ‘VHB';      
      8.              
      9.         var theTF = aDoc.textFrames;     
      10.         if (theTF.length > 0) {     
      11.             for (var j = 0 ; j <theTF.length; j++) {     
      12.                 var aTF = theTF[j];     
      13.                 var newString = aTF.contents.replace(searchString, replaceString);     
      14.                 if (newString != aTF.contents) {     
      15.                     theTF[j].contents = newString;     
      16.                 }     
      17.             }     
      18.         } 
      19.     } 
      20. };     
      21. FindAndReplaceScript_AllOpenDocuments();