Skip to main content
July 31, 2013
Question

How can I find and replace multiple words at once?

  • July 31, 2013
  • 1 reply
  • 1070 views

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 🙂

This topic has been closed for replies.

1 reply

BEGINNER_X
Legend
August 1, 2013

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

Inspiring
August 5, 2013

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();
}