添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
长情的消防车  ·  Adobe Illustrator CS6 ...·  3 周前    · 
越狱的冲锋衣  ·  青春榜样| ...·  8 月前    · 
潇洒的领结  ·  漫画与杂言:真假李逵·  10 月前    · 
伤情的消防车  ·  BEJ48 Team E - Wiki48·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to use javascript to update an Illustrator file. I have a script that will modify an open file in the desired way (really just a text find/replace, but the text is encoded in the Illustrator data). The problem is I have hundreds of these files that I want modified in the same way in a directory. Is there a way for me to do this without having to open every single one of these files?

I figure either: 1. there's a way to modify the existing javascript to read from the directory and load the files in the background, process them, save, and close. 2. I can write a Node.js script that can wrap the existing Illustrator javascript, but I'm not sure how to get it to recognize the "application" object and read the file the same way as when it's opened in Illustrator.

Thanks for any help!

Edit: Here's the functioning script (that only .

function FindAndReplaceScript_AllOpenDocuments(){      
        for(var i=app.documents.length -1; i > -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) {      
            for (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();   
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.