2 Replies Latest reply on Aug 5, 2013 1:32 AM by virender_CTS

    How can I find and replace multiple words at once?

    hobs707

      I need to be able to find and replace words into queens English. For example, I need to replace all instances of "color" with "colour," "tire" with "tyre" etc.

       

      I'm new to scripting, so simple answers would be appreciated :)

        • 1. Re: How can I find and replace multiple words at once?
          BEGINNER_X Level 3

          Hi hobs707,

           

          Please use the below code for your required output:

           

           

          Replace ("color", "colour")
          Replace("tire", "tyre")            
          //Replace("hobs707", "hobs007")     just copy and paste and edit the contents as your wish
          
          function Replace(input, output)
          {
          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
          app.findTextPreferences.findWhat = input;
          app.changeTextPreferences.changeTo = output;
          app.activeDocument.changeText();
          }
          

           

          If the above answer is correct please provide Correct Answers for me.

           

          Regards

          Beginner

          • 2. Re: How can I find and replace multiple words at once?
            virender_CTS Level 1

            Hi,

            I am also using this script but with additional features.

             

            Replace ("color", "colour")
            Replace("tire", "tyre")      

            function Replace(input, output)
            {
            app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
            app.findTextPreferences.findWhat = input;
            app.findChangeTextOptions.wholeWord = true;       // it will replace only wholeword  "retire" will not change to "retyre"
            app.findChangeTextOptions.caseSenstive = true;   // Color and color are different  
            app.changeTextPreferences.changeTo = output;
            app.activeDocument.changeText();
            }