I am trying to use a script to open multiple indesign files and perform several find and replaces using a delimited word file containing the searches, this script, plagerised from a quark one, opens files but doesnt S%26amp;R, can anybody see the error of my ways?
-- Indesign docs
set QFolder to ''Please locate the folder containing your Indesign documents...''
set Doc_Folder to (choose folder with prompt QFolder) as text
set theFiles to {}
tell application ''Finder''
tell folder Doc_Folder
repeat with i from 1 to count of files
if file type of file i is ''IDd5'' then
set end of theFiles to file i as text
end if
end repeat
end tell
end tell
-- Search Items
set QFile to ''Please locate your Tab Delimited Text file...''
set Search_File to (choose file with prompt QFile) as text
set Search_Rows to read file Search_File using delimiter {return}
set Search_Items to {}
repeat with This_Row in Search_Rows
set end of Search_Items to my GetTextItem(This_Row as text, tab, 0)
end repeat
--Process
tell application ''Adobe InDesign CS3''
activate
--Clear the find/change preferences.
repeat with oneFile in theFiles
open file oneFile
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 true
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 true
set include locked stories for find of find change text options to true
set include master pages of find change text options to true
set whole word of find change text options to true
tell document 1
repeat with ThisPair in Search_Items
set {searchstring, replaceString} to ThisPair as list
tell every story
try
set (every text where it is searchstring) to replaceString
end try
end tell
end repeat
end tell
close document 1 saving yes
end repeat
end tell
on GetTextItem(ThisString, ThisDelim, ThisItem)
-- ThisString -%26gt; String to look in
-- ThisDelim -%26gt; Text element that delimit the string
-- ThisItem -%26gt; Number of the element to return (0 for all)
copy the text item delimiters to OldDelims
set the text item delimiters to ThisDelim
if class of ThisItem is list then
set fromItem to (item 1 of ThisItem) as integer
set toitem to (item 2 of ThisItem) as integer
set arrItem to (text items fromItem thru toitem of ThisString)
else
set arrItem to every text item of ThisString
end if
set the text item delimiters to OldDelims
if class of ThisItem is list then
return arrItem as text
else
if ThisItem is not equal to 0 then
return (item ThisItem of arrItem) as text
else
return arrItem -- return every items
end if
end if
end GetTextItem
Thanks
Multi search and replace using excel...