My objective is to extract the folder name from the file path of my linked images in InDesign document. My script is as follows:-
tell application "Adobe InDesign CS2"
activate
tell document 1
set theLink to every link
repeat with i from 1 to count of theLink
set oriDelims to text item delimiters of AppleScript --puts the current delimiters into a variable
set theImagePath to file path of item i of theLink --extract full path
set text item delimiters of AppleScript to {":"} --uses the colon as the new delimiter
set theImageName to last text item of theImagePath --extract file name
set text item delimiters of AppleScript to oriDelims --resets the old delimiters
display dialog theImageName
end repeat
end tell
end tell
As you can see, I can easily extract the file name by coding “set theImageName to last text item of theImagePath”; but I couldn’t figure out how to extract the folder name by coding the 2nd last text item?
Please help! Thanks in advance!