Hi All,
With the help of Stefen I have completed this the below code and still I am facing two problem. I know some one can help me out.
This script is basically running through terminal see below command:
on run argv
tell application "Adobe InDesign CS4"
set thePath to (POSIX file (item 1 of argv)) as string
if exists ((thePath) & (item 2 of argv) & ":" & (item 2 of argv) & ".indd") then
set SavePath to (thePath & item 2 of argv & ":" & item 2 of argv & ".indd")
set myFolderPath to (thePath & item 2 of argv & ":")
set myDocument to open (thePath) & (item 2 of argv) & ":" & ((item 2 of argv) & ".indd")
if modified of myDocument is true or saved of myDocument is false then
save myDocument to SavePath
end if
tell active document
repeat with oneLink in (get links)
set linkPath to file path of oneLink
if linkPath is not (myFolderPath & name of oneLink) then
set movedFile to my processLink(linkPath)
if movedFile is not missing value then
relink (contents of oneLink) to movedFile
update oneLink
end if
end if
end repeat
end tell
end if
end tell
end run
on processLink(link)
tell application "Finder"
tell file link
set linkFileName to its name
display dialog linkFileName
set myFolderPath to its container as text
display dialog myFolderPath
set linkFileExtension to name extension
end tell
if exists file (myFolderPath & linkFileName) then
set {button returned:buttonReturned} to display dialog "Image with the same file name resides in the cache folder." buttons {"Rename", "Overwrite", "Ignore"}
if buttonReturned is "Overwrite" then
return (duplicate file link to folder myFolderPath with replacing) as alias
else if buttonReturned is "Rename" then
return
else
return (myFolderPath & linkFileName) as alias
end if
else
return (duplicate file link to folder myFolderPath) as alias
end if
end tell
end processLink
Save this script as test.scpt to “Macintosh:Test:” folder, create one indesign document to location of “Macintosh:File:test.indd”, place one image called image1.eps from desktop, second image called image1.eps from “Macintosh:” and third from image1.eps from “Macintosh:File:”.
Launch Terminal and enter the below command and hit return:
osascript “Macintosh:Test:test.scpt” “Macintosh” “File”
If user click on Overwrite then it should copy desktop image to “Macintosh:File:” location as well as other file to this location only and then re-link those images from this location.
If user click on Ignore then it should not copy any files but all images with the same name should link from image1.eps already exists in “Macintosh:File:” folder.
If user click on Rename it should display an alert and exit from code.
I know somewhere I am doing silly mistake or I am just out of my mind so it is not working as expected.
Regards,
Poo