Copy link to clipboard
Copied
I need to find & replace a string of text. I tried FindChangeByList script which it does work but I need to be batch over 300 ID documents. Open/ find/ replace/ save/ close)
I found this script & modified some lines but Im getting an error -10006 Can't set object or data to object or data. I checked the dictionary but I am in blank (I'm not a scripter at all but I like applescript) After spending hours trying to figure it out by myself I have to throw the towel. I understand the concept. Please any guidance or tips will help me to make it work.
set OLDid to {"WRT11-TY"} -- set up the data lists to be exchanged --find this
set NEWid to {"WRT11-TYA"} -- replace with this
set source_folder to choose folder with prompt "Select folder containing InDesign docs" with multiple selections allowed without invisibles
tell application "Finder" to set item_list to (every item where name ends with "indd") of folder source_folder asalias list --only ID docs can be selected
tell application "Adobe InDesign CS4"
activate
repeat with DocAlias in item_list --(loops thru ID docs)
set doc to open DocAlias
tell document 1
repeat with swap from 1 to (number of items of OLDid) -- swap is the list index
set oldReference to item swap of OLDid -- Get an old ID...
set newReference to item swap of NEWid -- 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
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 repeat -- Next 'find' string; next 'change to' string
end tell
close document 1 saving yes
end repeat
end tell
Copy link to clipboard
Copied
Hi,
could just ran it with ID CS 5.5 under OSX 10.7.4.
Did a few changes ... works here. You should think of adding some errorhandling!
set OLDid to {"Maus", "Katze"} -- set up the data lists to be exchanged --find this
set NEWid to {"Haus", "Hund"} -- replace with this
set source_folder to choose folder with prompt "Select folder containing InDesign docs"
tell application "Finder" to set item_list to (every item where name ends with "indd") of source_folder as alias list
tell application "Adobe InDesign CS5.5"
activate
--clear fields ...
set find text preferences to nothing
set change text preferences to nothing
-- set find options
set case sensitive of find change text options to false
set include footnotes of find change text options to false
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 false
set whole word of find change text options to false
repeat with DocAlias in item_list --(loops thru ID docs)
set doc to open DocAlias
repeat with swap from 1 to count of OLDid -- swap is the list index
set oldReference to item swap of OLDid -- Get an old ID...
set newReference to item swap of NEWid -- 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 1
change text -- and 'change text' swaps the 'find' text field with the 'Change to' text field in the Find/Change dialog box
end tell
end repeat -- Next 'find' string; next 'change to' string
close doc saving yes
end repeat
set find text preferences to nothing
set change text preferences to nothing
end tell
Please don't forget to set your findoptions!
Hope it'll work
Hans-Gerd Claßen