Copy link to clipboard
Copied
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
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,
...
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Can you share a sample file (or a couple of sample files)?
Also, is the location always the same (word) inside the 12-packs?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
Hey Carlos,
This seems to work well.
Any chance you could make it work with multiple text entries and replaces?
Thanks!
Copy link to clipboard
Copied
Hi a.melv, it seems possible. Can you share more details about your needs?
Copy link to clipboard
Copied
Hey Carlos,
It's all good. The deadline has past anyhow.
Thanks!
Copy link to clipboard
Copied
Hey Carlos,
I think I have a similar issue. would you be willing to help?
I'm basically just trying to change multiple.ai files they all have a text box that says "Fall 2018" and I want them all to change to "Winter 2018".
However, I also need to figure out how to change the font size of "Winter" so that it will fit in a text box, as well as change a layer title from "F18" to "W18".
Do you know an efficient way of doing this rather than just going into 200 files and manually changing them?
Any help is appreciated. Thank you!
Copy link to clipboard
Copied
Carlos, this script has really changed my workflow! What would you suggest to do multiple search queries at once? I tried creating more variables and adding to the for loop, but it wasn't working properly...I'm not sure if I'm getting syntax wrong or what.
I've tried just creating additional search and replace variables as well as an additional new_string variable. That just ran the second query, so I created new tframe and tframes variables and had the same result with the second one running...
// findReplace.jsx
// carlos canto
// https://forums.adobe.com/thread/2484457
function main () {
var idoc, search_string, replace_string, search_string1, replace_string1, tframes, tframes1, i, tframe, tframe1, new_string, new_string1=0;
for (var a=0; a<app.documents.length; a++) {
idoc = app.documents;
search_string = /\d+\/\d+\/(18|19)/gi; // g for global search, remove i to make a case sensitive search
replace_string = "01/30/19";
search_string1 = /(REV) \dv\d+/gi; // g for global search, remove i to make a case sensitive search
replace_string1 = "$1 4v0";
tframes = idoc.textFrames;
tframes1 = idoc.textFrames;
for (i = 0 ; i < tframes.length; i++) {
tframe = tframes;
tframe1 = tframes;
new_string = tframe.contents.replace(search_string, replace_string);
new_string1 = tframe1.contents.replace(search_string1, replace_string1);
if (new_string != tframe.contents) {
tframe.contents = new_string;
}
if (new_string1 != tframe1.contents) {
tframe1.contents = new_string1;
}
}
}
}
main();
Copy link to clipboard
Copied
Hello Wayne and all pal, may I ask what is the exact step to copy the above script/code, and successfully run it to multiple opened AI file? Why it seemed all knows the step how to copy/save this code to what format, and open/import it in or with what? Assuming I have zero knowledge in script/code.
Do I have to save it as Applescript of .jsx file? which function/feature in Illustrator can import or run these code?
MAY I ASK THE EXACT STEPS TO RUN THIS CODE:
1). starting from copying it via web browser;
2). change xxxxxx in script to the needed find text-string;
3). replace "NEW YORK" in script to the needed replace text-string;
4). open ???? application, and paste these code into ????, save in ????? format;
5). open Adobe Illustrator cc, and the multiple AI files;
6). then....what?
THANKS SO MUCH
Copy link to clipboard
Copied
Hello Wayne, I just googled how to run script in AI. And it did work! I"ll make appropriate donation to your Paypal. Thanks! (the only one thing I wanna share is that, if I copy/paste the code to text editor, and save as .jsx file, it doesn't work. I have to duplicate one of AI's default .jsx file, and replace the text, that works!
Copy link to clipboard
Copied
glau30624370 schrieb
if I copy/paste the code to text editor, and save as .jsx file, it doesn't work. I have to duplicate one of AI's default .jsx file, and replace the text, that works!
The text editor needs to set up to make TXT files.
By default many text editors are set to make RTF.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This could also be done with actions in Batch mode, but as you are probably dealing with 400 different locations you could only process 8 files at once.
In case you are going to set up similar files in the future, I'd recommend to take a look at Illustrator's text variables (see Variables palette).
Moreover, there are applications that can find and replace across multiple files in one whack, but in my experience they do not work very well with the .eps file format.
Copy link to clipboard
Copied
InDesign is great about Find & Replace function.
Even now, this function in Macromedia FreeHand MX is still stronger than Illustrator.
This function of Illustrator has to be improved.
Include InDesign document for colors and make these changes with "Ink Alias" function.
Copy link to clipboard
Copied
Thanks for adding refreshing thoughts to this topic, Ceyhun.
But may I ask you what it has to do with the initial request?
(InDesign's Ink Alias?)
Copy link to clipboard
Copied
The Ink Alias function provides ease of gathering the colors contained in the document under the specified spot colors. Photoshop lets you change colors from Illustrator documents without changing the original.
Copy link to clipboard
Copied
Yes, but this is completely unrelated to this thread.
Please reread Wayne's initial request.
Copy link to clipboard
Copied
You're right. The Find Multiple Documents function took me directly to InDesign.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Thank so much Carlos! I've tried so many scripts and this one finally does what I've been looking for 🙂
Thank you!