I’ve got a script that saves illustrator files. I thought the default save option was to ask, but instead my script ignores saving if an existing file of the same name is present, and doesn’t error out.
Saving with ‘replacing’ replaces the old file, but how do I force illustrator to ‘ask’ before overwriting an existing file.
Regards
Santa
set ptd to path to desktop as text
set savePath to (ptd & "ftp Downloads:Saved.eps") as text
tell application "Adobe Illustrator"
activate
save current document in file savePath as eps ¬
with options {class:EPS save options, compatibility:Illustrator 8 ¬
, preview:color Macintosh ¬
, embed linked files:true ¬
, include document thumbnails:true ¬
, embed all fonts:true ¬
, CMYK PostScript:true ¬
, PostScript:level 2} with replacing
end tell
It’s ok, i double checked the dictionary and it’s only possible for the Flash format saving.
So I’ve had to write a routine to check for the filename first.
Regards
Santa
tell application "Adobe Illustrator"
activate
delay 1
set bypass to true
repeat
set savePath to ContainerFolder & "3-ENGRAVE READY:" & tempWindowName & ".eps" as text
tell application "Finder"
if exists file savePath then
activate
display dialog "The file '" & tempWindowName & ".eps' already exists. Do you want to rename it or overwrite it?" buttons {"Cancel", "Change Name", "Overwrite it"} default button 2
set temp to the button returned of the result
set bypass to (temp is in {"Overwrite it", "Change Name"})
if temp = "Change Name" then
display dialog "Change Name to..." default answer tempWindowName buttons {"OK"} default button 1
set tempWindowName to the text returned of the result
end if
if temp = "Overwrite it" then exit repeat
else
exit repeat
end if
end tell
end repeat
if bypass then
try
save current document in file savePath as eps ¬
with options {class:EPS save options ¬
, compatibility:Illustrator 8 ¬
, preview:color Macintosh ¬
, embed linked files:true ¬
, include document thumbnails:true ¬
, embed all fonts:true ¬
, CMYK PostScript:true ¬
, PostScript:level 2} with replacing
--close current document saving no
my SayTheSound("Document saved")
on error errmsg
set msgString to "I couldn't automatically save the file, please save it manually. " & return & errmsg
my Showmessage(msgString)
my SayTheSound("I couldn't automatically save the file, please save it manually.")
end try
end if
end tell