2 Replies Latest reply on Dec 28, 2011 11:10 AM by jagriffith12

    Changing Find & Replace in Story to in All Documents

    jagriffith12

      I have a set of code that finds and replaces an array of various information, right now it just changes in story. I'd like to have it change in All Documents so that i can open multiple files at the same time and run the script on all of them at once.

       

      Any help would be greatly appreciated!

       

       

       
      var ReplaceArray = [["kochequipment.com", "UltraSourceUSA.com"], ["KOCH EQUIPMENT SERVICES", "ULTRAVAC SERVICES"], ["Koch Equipment Services", "Ultravac Services"], ["KOCH EQUIPMENT LLC", "ULTRASOURCE LLC"], 
                                              
      ["Koch Equipment LLC", "UltraSource LLC"], ["Koch Equipment", "UltraSource"], ["KOCH", "ULTRASOURCE"], ["Koch", "UltraSource"], ["  ", " "]];
              
      for(j=0; j<ReplaceArray.length; j++)
              
      {
                  
      var curArray = ReplaceArray[j];
                  
      ChangeInStory(curArray[0],  curArray[1])
              
      }
      
      
      function ChangeInStory(find_text, change_text, findType){
      
      try{
          
      app.findTextPreferences = app.changeTextPreferences = null;
          
      
          
      app.findChangeTextOptions.wholeWord = true;
          
      app.findChangeTextOptions.caseSensitive = true;
          
      
          
      app.findTextPreferences.findWhat= find_text;
          
      app.changeTextPreferences.changeTo = change_text;
          
      app.changeText();
      
      
          
      app.findTextPreferences = app.changeTextPreferences = null;
          
      }
      
      catch(e)
      
      {
              
      throw (e);
          
      }
      
      }
      
      
        • 1. Re: Changing Find & Replace in Story to in All Documents
          csm_phil Level 4

          Hi jag,

           

          I have modified your JS code, now its working fine all the opened indesign documents. i changed the below bold highlighted lines only in your script.

           

          "app.documents.everyItem().changeText();"

           

           

          var ReplaceArray = [["Test", "Complete"]];
                  for(j=0; j<ReplaceArray.length; j++)
                  {
                      var curArray = ReplaceArray[j];
                      ChangeInStory(curArray[0],  curArray[1])
                  }
          
          
          
          function ChangeInStory(find_text, change_text, findType){
          try{
              app.findTextPreferences = app.changeTextPreferences = null;
          
              app.findChangeTextOptions.wholeWord = true;
              app.findChangeTextOptions.caseSensitive = true;
          
              app.findTextPreferences.findWhat= find_text;
              app.changeTextPreferences.changeTo = change_text;
              app.documents.everyItem().changeText();
          
          
          
              app.findTextPreferences = app.changeTextPreferences = null;
              }
          catch(e)
          {
                  throw (e);
              }
          }
          

           

          thx

          csm_phil

          • 2. Re: Changing Find & Replace in Story to in All Documents
            jagriffith12 Level 1

            Is there an easy way to automatically relink images in the same fashion?

             

            Like said all of my documents had logo.ai in them, and i wanted to relink all instances in the open documents like with find & replace above, to logo1.ai

             

            Could this script be modified to do that as well?