I want to relink LoRes images to HiRes images. Images in LoRes folder are named like Image1.jpg, image2.jpg… Images in HiRes folder are named like image1.tif, image2.tif… Please note the different extension.
I’m stuck with this line:
if name of myNewFileName = name of LinkName then
What ever I do to the script, I allways get the samekind of error: Can’t get name of image1.
And I can’t figure out what is the mistake I have made…
–Open this script in a new Script Editor window.
set myProcessedLinks to {}
set listFiles to {}
set myFolder to choose folder with prompt “Select Lo-Res”
set myNewFolder to choose folder with prompt “Select Hi-Res”
tell application “InDesign CS”
activate
set myDocument to active document
tell myDocument
set outdateLinks to every link whose status is link out of date
repeat with OODLinks from ( count outdateLinks ) to 1 by -1
update link of item OODLinks of outdateLinks
end repeat
set IDLinks to every link whose status is normal
– Iterate backwards through the links to avoid invalidating objects.
repeat with myCounter from ( count IDLinks ) to 1 by -1
set myLink to item myCounter of IDLinks
– Process only image links.
set myLinkType to link type of myLink
– If statement could be expanded to include other image types.
if myLinkType = “TIFF” or myLinkType = “JPEG” or myLinkType = “Photoshop” then
set LinkName to name of myLink
set LinkName to my remove_link_extension color=red [/color]
set theImage to parent of myLink
set theFrame to parent of theImage
– get the path
set ImagePath to file path of item myCounter of IDLinks as string
else if ImagePath is in myProcessedLinks then
set myLink to update myLink
end if
end repeat
tell application “Finder”
set myFiles to every file of folder myNewFolder
end tell
repeat with myCounter from 1 to count of items in myFiles
set myFile to item myCounter of myFiles as string
set myNewFileName to my myMakeFileName ( myNewFolder , myFile as alias )
if name of myNewFileName = name of LinkName then
relink myLink to myNewFileName
set myLink to update myLink
set theImage to parent of myLink
set theFrame to parent of theImage
fit theFrame given proportionally
copy myFileName to end of myProcessedLinks
end if
end repeat
if ImagePath is in myProcessedLinks then
set myLink to update myLink
exit repeat
end if
end tell
end tell
on remove_link_extension color=red [/color]
if LinkName contains “.” then
set delim to AppleScript ’s text item delimiters
set AppleScript ’s text item delimiters to “.”
set LinkName to text 1 thru text item -2 of LinkName
set AppleScript ’s text item delimiters to delim
return LinkName
end if
end remove_link_extension
on myMakeFileName ( myNewFolder , myFile )
set myFileInfo to info for myFile
set myFileName to name of myFileInfo
set myFolderName to myNewFolder as string
if myFileName contains “.” then
set myOldDelimiters to text item delimiters
set text item delimiters to “.”
set myFileName to text item 1 of myFileName
set text item delimiters to myOldDelimiters
end if
set myNewFileName to myFileName
return myNewFileName
end myMakeFileName
Kari