I think I’m getting screwed over by some compatibility issue, or there’s a little blind spot my noobness isn’t getting.
I’m trying to create a document-wide “Change All” script that rotates through different ‘find’ and ‘change to’ strings. I have a multi-page, multi-frame ID document with a range of old labels (a short string of characters) sprinkled liberally throughout, in various formats. I need to find each instance of each label and change it to a new label.
I have two lists. Item 1 in list “OLDid” is to be replaced by item 1 of “NEWid”, etc throughout the document.
The labels do not appear in any order in the InDesign document, and there may be one or several instances of a particular label.
But I keep running into errors. This compiles, but I’m not invoking a command correctly. Grrr. Here’s the pared back version:
-- Read in two arrays.
-- In the current, open InDesign document
-- replace all instances of OLDid with NEWid,
-- preserving the style/format of the original text
set OLDid to {"oldstring1", "oldstring2", "oldstring3", "oldstring4", "oldstring5"}
set NEWid to {"newstringA", "newstringB", "newstringC", "newstringD", "newstringE"}
tell application "Adobe InDesign CS3"
tell document 1
repeat with swap from 1 to 5
set testString to item swap of OLDid
set find what of find text preferences to testString
end repeat
end tell
end tell
The hi-lighted line in Script Editor is “set find what of find text preferences to testString”
I haven’t even GOT to the ‘change to’ section and I’m already stymied. I’ve been at this for two days. Would someone please tell me why I suck so hard?
-Oro