Copy link to clipboard
Copied
These days I've been trying to modify the FindChangeByList script, but there's a huge problem. The words that I want to change are in my native language, Farsi, which is a Right-to-left one. Although the FindChangeList text file is in UTF-8 encoding, it doesn't understand the words I've typed. I searched in the community and found someone who managed to do it by chance. and here's the link:
https://community.adobe.com/t5/indesign-discussions/is-built-in-find-change-by-list-script-unicode-c...
I'm attaching the screenshot of my txt file and the result in the Find/change dialog box
Ahh, I used the JS version of the script and you are using the Applescript version and hence the disparity in the findchangelist file. Can you use the string I gave with the jsx version of the script, it did do some changes when I tried.
-Manan
Copy link to clipboard
Copied
Hi @SunFlower16,
I don't have a MENA version of InDesign installed but can you share an InDD document and also FindChange text file for me to test
-Manan
Copy link to clipboard
Copied
Me neither, dear Manan. I've got a newer version of Indesign, 2021 v16.0.2
Here's the link to my indd and txt file: https://drive.google.com/drive/folders/1HjWTibTBXTHYTKM43R80VFeXIwdDv0PT?usp=sharing
Copy link to clipboard
Copied
Hi @SunFlower16,
There are issues with the property names in your FindChange string. I fixed and it does change something though I can't verify it as I can't read the language. See the following string and notice find what is changed to findWhat etc
grep {findWhat:"ŁŚÆŲ§Ł"} {changeTo:"ŁŚÆŲ§Ł ŁŚÆŲ§Ł ŁŚÆŲ§Ł"} {includeFootnotes:true, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false} Find all double spaces and replace with single spaces.
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Ahh, I used the JS version of the script and you are using the Applescript version and hence the disparity in the findchangelist file. Can you use the string I gave with the jsx version of the script, it did do some changes when I tried.
-Manan
Copy link to clipboard
Copied
I greatly appreciate you dear Manan. Using the Applescript was the reason I fail every time I wanted to use it. I wasn't aware that there's a similar script in jsx. Now I'm able to do whatever I want using it.
Out of curiosity, is it possible to merge the FindChangeByList.jsx and FindChangeList.txt, to have only one file? I'm willing to share my file with my coworkers and having just one file is more convenient for them.
Copy link to clipboard
Copied
The only file you need to share with your coworkers is FindChangeList.txt as they would already have the jsx file installed with their InDesign application. However, if you still want the merge it can be done, do let me know I will do it
-Manan
Copy link to clipboard
Copied
Yes I really prefer merging them. I don't want them to overwrite my modified file on the default file, as I copied the jsx and txt file next to the User's jsx files.
Copy link to clipboard
Copied
Try the following code, you can make entries in the array defined at the top named findChangeList
//FindChangeByList.jsx
//An InDesign JavaScript
/*
@@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009
*/
//Add the strings as an element of the following array, just add a , and add the string by enclosing it in ''
var findChangeList = [
'grep {findWhat:"ŁŚÆŲ§Ł"} {changeTo:"ŁŚÆŲ§Ł ŁŚÆŲ§Ł ŁŚÆŲ§Ł"} {includeFootnotes:true, includeMasterPages:false, includeHiddenLayers:true, wholeWord:false}'
]
main();
function main(){
var myObject;
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if(app.documents.length > 0){
if(app.selection.length > 0){
switch(app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Cell":
case "Column":
case "Row":
case "Table":
myDisplayDialog();
break;
default:
//Something was selected, but it wasn't a text object, so search the document.
myFindChangeByList(app.documents.item(0));
}
}
else{
//Nothing was selected, so simply search the document.
myFindChangeByList(app.documents.item(0));
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
}
function myDisplayDialog(){
var myObject;
var myDialog = app.dialogs.add({name:"FindChangeByList"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Search Range:"});
}
var myRangeButtons = radiobuttonGroups.add();
with(myRangeButtons){
radiobuttonControls.add({staticLabel:"Document", checkedState:true});
radiobuttonControls.add({staticLabel:"Selected Story"});
if(app.selection[0].contents != ""){
radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
}
}
}
}
var myResult = myDialog.show();
if(myResult == true){
switch(myRangeButtons.selectedButton){
case 0:
myObject = app.documents.item(0);
break;
case 1:
myObject = app.selection[0].parentStory;
break;
case 2:
myObject = app.selection[0];
break;
}
myDialog.destroy();
myFindChangeByList(myObject);
}
else{
myDialog.destroy();
}
}
function myFindChangeByList(myObject){
var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
var myStartCharacter, myEndCharacter;
//Loop through the find/change operations.
for(var i = 0; i < findChangeList.length; i++){
myLine = findChangeList[i];
//Ignore comment lines and blank lines.
if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")||(myLine.substring(0,5)=="glyph")){
myFindChangeArray = myLine.split("\t");
//The first field in the line is the findType string.
myFindType = myFindChangeArray[0];
//The second field in the line is the FindPreferences string.
myFindPreferences = myFindChangeArray[1];
//The second field in the line is the ChangePreferences string.
myChangePreferences = myFindChangeArray[2];
//The fourth field is the range--used only by text find/change.
myFindChangeOptions = myFindChangeArray[3];
switch(myFindType){
case "text":
myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
case "grep":
myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
case "glyph":
myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
}
}
}
}
function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change preferences before each search.
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
myFoundItems = myObject.changeText();
//Reset the find/change preferences after each search.
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
}
function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change grep preferences before each search.
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;
var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
var myFoundItems = myObject.changeGrep();
//Reset the find/change grep preferences after each search.
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;
}
function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change glyph preferences before each search.
app.changeGlyphPreferences = NothingEnum.nothing;
app.findGlyphPreferences = NothingEnum.nothing;
var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
var myFoundItems = myObject.changeGlyph();
//Reset the find/change glyph preferences after each search.
app.changeGlyphPreferences = NothingEnum.nothing;
app.findGlyphPreferences = NothingEnum.nothing;
}
-Manan