Dear all,
can anybody please help me?
I am quite new to CS6 server and tried to use the well-known "FindChangeByList.jsx" on a generated document, but it doesn't work...
I did some changes to the script as described in the Scripting User Guide for the server version, but I am not sure if this was right as two or three chnages didn't make sense to me...
1. Replace the main() function with the following:
function main(){ if(app.documents.length > 0){ //Provide a story object or a document object. myFindChangeByList(app.documents.item(0), false); } }
2. Delete the myDisplayDialog function.
3. Change the line:
var myFindChangeFile = "/c/FindChangeSupport/FindChangeList.txt";
to (you will have to fill in a valid file path for your system):
set myFindChangeFile to "yukino:FindChangeSupport:FindChangeList.txt"
--> Is this right?? This looked like AppleScript to me.
To me it made more sense to change it to
var myFindChangeFile = "FindChangeSupport/FindChangeList.txt";
Doesn't a relative path work if the .txt file is in the specified subfolder?
Which would be the right syntax for Windows path like "\\myserver\somefolder\myscriptfolder\FindChangeSupport\FindChangeList.txt"?
4. Delete the myFindChangeFile function.
--> I didn't find this function, I deleted the myFindFile function
5. Delete the myGetScriptPath function.
On CS6 desktop version I use the unchanged script version which works well and replaces the things defined in the txt file.
After my changes my complete script looks like this, but nothing is replaced...
//FindChangeByList.jsx //An InDesign CS4 JavaScript /* @@@BUILDINFO@@@ "FindChangeByList.jsx" 2.0.0.0 10-January-2008 */ //Loads a series of tab-delimited strings from a text file, then performs a series //of find/change operations based on the strings read from the file. // //The data file is tab-delimited, with carriage returns separating records. // //The format of each record in the file is: //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description // //Where: //<tab> is a tab character //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use). //findProperties is a properties record (as text) of the find preferences. //changeProperties is a properties record (as text) of the change preferences. //findChangeOptions is a properties record (as text) of the find/change options. //description is a description of the find/change operation // //Very simple example: //text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double dashes and replace with an em dash. // //More complex example: //text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price". // //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences. // //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped" //as shown in the example below: // //{findWhat:"\\s+"} // //For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html //or visit the InDesign Scripting User to User forum at http://www.adobeforums.com // main(); function main(){ if(app.documents.length > 0){ //Provide a story object or a document object. myFindChangeByList(app.documents.item(0), false); } function myFindChangeByList(myObject){ var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult; var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory; var myStartCharacter, myEndCharacter; var myFindChangeFile = "FindChangeSupport/FindChangeList.txt"; if(myFindChangeFile != null){ myFindChangeFile = File(myFindChangeFile); var myResult = myFindChangeFile.open("r", undefined, undefined); if(myResult == true){ //Loop through the find/change operations. do{ myLine = myFindChangeFile.readln(); //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; } } } while(myFindChangeFile.eof == false); myFindChangeFile.close(); } } } 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; }