-
1. Re: Find and Replace symbol content
michael_mandahl Nov 19, 2013 12:00 PM (in response to michael_mandahl)So I figured out how to select the symbols and break the link in a batch action. I found this script that will allow you to do a find and replace.
var active_doc = app.activeDocument;
var search_string = /© 2013/gi;
var replace_string = "© 2014";
var text_frames = active_doc.textFrames;
if (text_frames.length > 0)
{
for (var i = 0 ; i < text_frames.length; i++)
{
var this_text_frame = text_frames[i];
var new_string = this_text_frame.contents.replace(search_string, replace_string);
if (new_string != this_text_frame.contents)
{
this_text_frame.contents = new_string;
}
}
}
The only problem with this script is that it is only changing one instance of the © 2013 to © 2014. Each document has two instances that need to be changed. How would I change the script to do this?
thanks
-
2. Re: Find and Replace symbol content
michael_mandahl Nov 19, 2013 12:08 PM (in response to michael_mandahl)Sorry, the actual script I've been using for find and replace was written by Carlos. here:
var idoc = app.activeDocument;
var sel = idoc.selection[0];
var searchString = "© 2013";
var replaceString = "© 2014";
var searchStringLength = searchString.length;
var idx = sel.contents.search (searchString);
if (idx == -1) {
alert('string not found');
}
else {
var range = sel.characters[idx];
range.length = searchStringLength;
range.contents = replaceString;
}
