Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

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

$
0
0

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(); 

Viewing all articles
Browse latest Browse all 12845

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>