Skip to main content
Participant
April 28, 2018
Answered

Find and replace text across multiple Illustrator files

  • April 28, 2018
  • 4 replies
  • 17045 views

With the printers now looking for AI or EPS files, I have run into this problem a lot.

Is there a way to find and replace text across multiple Illustrator files like you can do in Indesign & Dreamweaver? It would save me days of double-clicking and pasting.

Please help.

Wayne

    Correct answer CarlosCanto

    Below is a link to an example folder. I have to replace the XXXX with New York City in all 8 EPS files.

    Then repeat that for about 400 locations.

    WeTransfer


    Hi Wayne, here's a script that replaces XXXX with NEW YORK across all open documents. Let me know if you need help changing the script to find something more meaningful.

     

     

    // findReplace.jsx
    // carlos canto
    // https://forums.adobe.com/thread/2484457
    
    function main () {
        var idoc, search_string, replace_string, tframes, i, tframe, new_string, counter=0;
        for (var a=0; a<app.documents.length; a++) {
            idoc = app.documents[a];
    
            search_string = /xxxx/gi; // g for global search, remove i to make a case sensitive search
            replace_string = "NEW YORK";
             
            tframes = idoc.textFrames;
             
            for (i = 0 ; i < tframes.length; i++) {
                tframe = tframes[i];
                new_string = tframe.contents.replace(search_string, replace_string);
    
                if (new_string != tframe.contents) {
                    tframe.contents = new_string;
                    counter++;
                }
            }
        }
        alert(counter + ' changes were made');
    }
    
    main();

     

     

     

    4 replies

    Participant
    April 9, 2025

    Hi @CarlosCanto, thank you very much! The script seems to be working just fine. The only thing it messes up is formatting. Once there's some text in bold or with a different color at the beginning of the text area, the script changes the string but the whole text area also inherits the formatting from the very first character in the text area. Could you please provide some clarification on how to deal with this? Thank you so much!

    CarlosCanto
    Community Expert
    Community Expert
    April 5, 2020

    here you go, I added a prompt to enter search/replace strings. You're correct, if you have a lot of text, Illustrator will freeze but it's still working on the background. Just wait for the scrip to finish. I'll add a progress bar when I have more free time.

     

    // findReplace v4.jsx
    // carlos canto
    // https://forums.adobe.com/thread/2484457
    
    function main () {
        var idoc, search_string, replace_string, tframes, i, tframe, new_string, counter=0;
        
        search_string = Window.prompt ('Enter Search string', 'search string', 'Find/Replace Across All Open Documents');
        
        if (search_string == null) {
            alert ('Cancelled by user');
            return;
        }
    
        replace_string = Window.prompt ('Enter Replace string', 'replace string', 'Find/Replace Across All Open Documents');
        
        if (replace_string == null) {
            alert ('Cancelled by user');
            return;
        }
    
        for (var a=0; a<app.documents.length; a++) {
            idoc = app.documents[a];
             
            tframes = idoc.textFrames;
             
            for (i = 0 ; i < tframes.length; i++) {
                tframe = tframes[i];
                new_string = tframe.contents.replace(new RegExp(search_string, 'g'), replace_string);
                
                if (new_string != tframe.contents) {
                    tframe.contents = new_string;
                    counter++;
                }
            }
        }
        alert(counter + ' changes were made');
    }
    
    main();
    
    

     

    blockstation
    Known Participant
    April 5, 2020

    Thank you very much Carlos!

    This is fantatstic.

    Do you know, which GREP commands work with Illustrator?

    I just tried the full stop which works like expected, also with the plus modifier.

    For troubleshooting i tried to wrap your script into an undo functionality like it has been described here:
    https://indesignsecrets.com/add-undo-to-your-script.php
    but this only seems to work with InDesign scripts.

    Thank you very much & stay healthy!

    blockstation
    Known Participant
    April 4, 2020

    Hi Carlos!
    The Scipt could be really useful for me.

    Might it be possible to have something like a search & replace dialog instead of the necesitty to change the code?

    This would be fantastic!

    While doing a search & replace on documents with a large amount of text boxes it seems like illustrator crashes but mostly it doesn't - it's only not responding. I guess thats because the script needs to go through all text boxes in all open documents.

    So something like a progress bar would also be very useful.

    Kurt Gold
    Community Expert
    Community Expert
    April 29, 2018

    In older versions of Illustrator that used to work with Batch processing action(s), but I can remember that some users claimed that it doesn't work anymore or not as expected.

    Which version of Illustrator are you using? What are you trying to find and replace? Just one single word or various instances of single words? Or something else?

    Participant
    May 3, 2018

    I am running CC2018.

    Here is the Scenario. I have 12 eps files with the client logo and the location (live type) underneath. The 12 files are just different brand standard colors.

    There are 430 different locations (430X12). Instead of hitting paste 12X430 times, I would like to do find and replace 430 times.

    Kurt Gold
    Community Expert
    Community Expert
    May 3, 2018

    Can you share a sample file (or a couple of sample files)?

    Also, is the location always the same (word) inside the 12-packs?