Hello. Can anyone offer any advice on the following …
I’m new to Applescripting, and I’ve created an Applescript that performs a Find/Change on all open InDesign (CS5.5) documents, using the contents of a tab-delimited text file stored on a local server. The script works fine, but is there anyway I can speed up its operation?
One issue is that there isn’t any feedback in the script: it’s currently run with the Find/Change dialog visible so that the actual terms can be seen as each doc is searched, giving a basic kind of feedback. I know this slows it down, but until I can find a way of giving users a visual indication of what the script is doing, or at least where it’s at in the process, I can’t think of an easier method.
So, aside from hiding anything on-screen that would indicate the Find/Change taking place, can my code be ‘enhanced’
Here’s the relevant Find/Change bit …
-- We're getting there... create a list from the text file
repeat with i from 1 to count of findReplaceList
set item i of findReplaceList to every text item of item i of findReplaceList
end repeat
set AppleScript's text item delimiters to {ASTID}
-- And tell InDesign to Find/Replace using our lists
tell application "Adobe InDesign CS5.5" -- NOTE: you'll need to alter this line to your CS version
activate
-- Clear Find/Replace options and setup. Note that whilst all options are included here,
-- some are commented-out, so please set those you wish below.
--Clear the find/change preferences.
-- set find text preferences to nothing
-- set change text preferences to nothing
-- Set the find options.
set case sensitive of find change text options to false
set include footnotes of find change text options to true
set include hidden layers of find change text options to false
set include locked layers for find of find change text options to false
set include locked stories for find of find change text options to false
set include master pages of find change text options to true
set whole word of find change text options to true
set properties of find text preferences to {font style:nothing}
set properties of change text preferences to {font style:nothing}
set openDocs to every document of application "Adobe InDesign CS5.5" -- create list of open files
repeat with openDocs from 1 to (count of openDocs)
repeat with swap from 1 to (count of findReplaceList) -- swap is the list index
set oldReference to item 1 of item swap of findReplaceList -- Get an old ID...
set newReference to item 2 of item swap of findReplaceList -- Get the corresponding new ID...
set find what of find text preferences to oldReference -- and load each string into the 'Find'
set change to of change text preferences to newReference -- and 'Change to' boxes of the Find/Change dialog box
-- tell document from the list of open files
set hitList to find text -- 'find text' creates a list of matching strings...
repeat with foundIt in hitList
change text -- and 'change text' swaps the 'find' text field with the 'Change to' text field in the Find/Change dialog box
end repeat -- Keep doing this until you run out of items in 'hitList'
-- end tell
end repeat -- Next 'find' string; next 'change to' string
end repeat -- Next document please!
As you can see, I’ve commented like mad so I don’t forget what it all means! Any help or advice will be welcome.
Model: MacPro Qaud Xeon
AppleScript: 2.1.2
Browser: Safari 533.20.27
Operating System: Mac OS X (10.6)