How can I run an Illustrator javascript on all files in a directory? -
i'm trying use javascript update illustrator file. have script modify open file in desired way (really text find/replace, text encoded in illustrator data). problem have hundreds of these files want modified in same way in directory. there way me without having open every single 1 of these files?
i figure either: 1. there's way modify existing javascript read directory , load files in background, process them, save, , close. 2. can write node.js script can wrap existing illustrator javascript, i'm not sure how recognize "application" object , read file same way when it's opened in illustrator.
thanks help!
edit: here's functioning script (that .
function findandreplacescript_allopendocuments(){ for(var i=app.documents.length -1; > -1; i--){ app.documents[i].activate(); var adoc = app.documents[i]; var searchstring = /oldtext/gi; var replacestring = 'newtext'; var thetf = adoc.textframes; if (thetf.length > 0) { (var j = 0 ; j <thetf.length; j++) { var atf = thetf[j]; var newstring = atf.contents.replace(searchstring, replacestring); if (newstring != atf.contents) { thetf[j].contents = newstring; } } } } }; findandreplacescript_allopendocuments(); }
yes,there way read directory:
var dir = folder.selectdialog("where?"); var files = dir.getfiles("*.eps"); for(var f = 0; f < files.length; f++){ var doc = app.open(files[f]); //your processing doc.close(saveoptions.savechanges); }
Comments
Post a Comment