I’ve made a script that suppose to change my blablabla_LR.tif to blablabla.tif, but even if the log says the name are the correct one, it just doesn’t relink the files.
Here is the script I have problem with:
set HRFolder to choose folder with prompt "Choose the High Res images folder"
set Mymissing to {return & return}
tell application "InDesign CS"
tell document 1
set theLinks to every link
repeat with i from 1 to count of theLinks
set thelink to item i of theLinks
set theName to name of thelink as Unicode text
if text -7 thru -1 of theName = "_LR.tif" then
set theName to (text 1 thru -8 of theName) & ".tif"
end if
get theName
set newpath to HRFolder & theName
try
relink thelink to newpath
on error
copy (theName & return) to end of Mymissing
end try
update thelink
end repeat
end tell
beep 2
display dialog "Finished."
display dialog "Cannot locate the High Res image: " & Mymissing
end tell
If anybody can help me understand why this doesn’t work, it’d be great.
TIA
Lesta
I kind of remember having this problem. I think it had something to do with the class I was feeding to relink. Try changing your unicode path to a string or alias.
here’s the final code for those of you who might find it useful.
--relinks files that end with _LR.tif with .tif
--version 1.0
set HRFolder to choose folder with prompt "Choose the High Res images folder"
set Mymissing to {return & return}
tell application "InDesign CS"
tell document 1
set theLinks to every link
repeat with i from 1 to count of theLinks
set thelink to item i of theLinks
set theName to name of thelink as Unicode text
if text -7 thru -1 of theName = "_LR.tif" then
set theName to (text 1 thru -8 of theName) & ".tif"
end if
set newpath to (HRFolder as Unicode text) & theName
try
relink thelink to newpath
on error
copy (theName & return) to end of Mymissing
end try
update thelink
end repeat
end tell
beep 2
display dialog "Finished."
if Mymissing is not {return & return} then
display dialog "Cannot locate the High Res image: " & Mymissing
end if
end tell