2 Replies Latest reply on Nov 19, 2013 12:08 PM by michael_mandahl

    Find and Replace symbol content

    michael_mandahl

      I have multiple documents using text as symbols. I need to change a ® 2013 to  a ® 2014 within the symbols. Without having to go into each document and double click on the symbol or break the link, is there a way to do a batch find and replace that will search within symbols to change text?

        • 1. Re: Find and Replace symbol content
          michael_mandahl Level 1

          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 Level 1

            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;

            }