I’m having trouble trying to get a group of EPS that were created in a graphing program to be opened and save-as’d by Illustrator 10 to the same location (replacing the original file). I’ve looked in the Actions function of Illustrator and saving as EPS is not a command it can record without applying the file name of the document used during the recording. I want to change “owners” of the eps’ so when I run a batch Actions set on it the option to save as AI (the default) will not continue to pop up).
Here are my latest attempt:
tell application “Finder”
display dialog “Welcome to the Delta Graph EPS to Illustrator EPS converterer. This helps when running the EAB Graph Colors Illustrator action.” & return & return & ¬
“Make sure all of you EPS are in one folder.” buttons {“OK”} default button 1
set sourceFolder to choose folder with prompt “Which folder would you like to convert?”
set targetPath to sourceFolder as string
set theFile to every file in sourceFolder
tell application “Adobe Illustrator 10.0.3”
launch
set user interaction level to never interact
repeat with i from 1 to count of theFile
open theFile
save current document as eps with options {compatibility:Illustrator 10, compressed:true, embed all fonts:true, PDF compatible:true}
close current document saving no
end repeat
end tell
end tell
So far from what I’ve learned Illustrator requires the term “current document” to save and close. I also know that one could try coercing the file path / name / “.eps” within the save command, but I haven’t had much luck with that either.
you just need to get the name and path of the file and add the in ‘filepath’ command. I modiified your code but didn’t test it though I think you’ll ge tthe idea
tell application "Finder"
display dialog "Welcome to the Delta Graph EPS to Illustrator EPS converterer. This helps when running the EAB Graph Colors Illustrator action." & return & return & ¬
"Make sure all of you EPS are in one folder." buttons {"OK"} default button 1
set sourceFolder to choose folder with prompt "Which folder would you like to convert?"
set targetPath to sourceFolder as string
set theFile to every file in sourceFolder
tell application "Adobe Illustrator 10.0.3"
launch
set user interaction level to never interact
repeat with i from 1 to count of theFile
set fName to name of current document
set savePath to sourceFolder & fName
open theFile
save current document as eps in savePath with options {compatibility:Illustrator 10, compressed:true, embed all fonts:true, PDF compatible:true}
close current document saving no
end repeat
end tell
end tell
I had to make a few modifications to get it to run, but thank you very much!!
Unfortunately I’m still running into the problem of Illustrator not doing a true save as and copying over the existing file. The problem lies in telling the app to both save as while closing “saving:no”…which obviously seems to contradict. If there was a way to close current document saving yes with options format:eps…then yada-yada…I could see it working, of course that route hasn’t worked for me either (I can’t even find the right wording to have the command compile correctly).
Current script:
tell application "Finder"
display dialog "Welcome to the Delta Graph EPS to Illustrator EPS converterer. This helps when running the EAB Graph Colors Illustrator action." & return & return & ¬
"Make sure all of you EPS are in one folder." buttons {"OK"} default button 1
set sourceFolder to choose folder with prompt "Which folder would you like to convert?"
set targetPath to sourceFolder as string
set theFile to every file in sourceFolder
tell application "Adobe Illustrator 10.0.3"
launch
set user interaction level to never interact
repeat with i from 1 to count of theFile
open item i of theFile
set fName to name of current document
set savePath to sourceFolder & fName as string
save current document as eps in (savePath as alias) with options {compatibility:Illustrator 10, compressed:true, embed all fonts:true, PDF compatible:true}
close current document saving no
end repeat
end tell
end tell
why don’t you just have the script make a converted folder and save it there . I would think you would want to keep the original in case the user picked the wrong folder or the file gets corrupt ?
Here is what I think the real problem is. Illustrator seem to have a problem assigning the creator type file type to files when it is overwriting the file so doing the above should solve the problem also you could move the files back to the sourceFolder after you have saved them to the converted folder and when the script is all done you could delete the converted folder so that your not leaving your mess behind !
What if you save the converted EPS files in a new subfolder?
tell application "Finder"
display dialog "Welcome to the Delta Graph EPS to Illustrator EPS converterer. This helps when running the EAB Graph Colors Illustrator action." & return & return & ¬
"Make sure all of you EPS are in one folder." buttons {"OK"} default button 1
set sourceFolder to choose folder with prompt "Which folder would you like to convert?"
set theFile to every file in sourceFolder
try
make new folder in sourceFolder with properties {name:"converted"}
set targetPath to (sourceFolder as string) & "converted:"
end try
end tell
tell application "Adobe Illustrator"
launch
--set user interaction level to never interact
repeat with i from 1 to count of theFile
open item i of theFile
set fName to name of current document
set savePath to sourceFolder & fName as string
save current document as eps in (savePath as alias) with options {compatibility:Illustrator 10, compressed:true, embed all fonts:true, PDF compatible:true}
close current document saving no
end repeat
end tell
That way you can see if the Illustrator save is happening. I haven’t had Illy 10 in a while and cannot test.
Mark that is what I was saying in my last post also lets clean up these this script alittle the illustrator tell block doesn’t need to be in the finder tell block and we certainly don’t need a finder tell block inside a finder tell block. Also if the finder can’t make the the folder then targetPath will not get defined I know how to fix this but see if one of you can find a way to ensure the folder and the target path are always set
tell application "Finder"
display dialog "Welcome to the Delta Graph EPS to Illustrator EPS converterer. This helps when running the EAB Graph Colors Illustrator action." & return & return & ¬
"Make sure all of you EPS are in one folder." buttons {"OK"} default button 1
set sourceFolder to choose folder with prompt "Which folder would you like to convert?"
set theFile to every file in sourceFolder
try
make new folder in sourceFolder with properties {name:"converted"}
set targetPath to (sourceFolder as string) & "converted:"
end try
end tell
tell application "Adobe Illustrator"
launch
--set user interaction level to never interact
repeat with i from 1 to count of theFile
open item i of theFile
set fName to name of current document
set savePath to sourceFolder & fName as string
save current document as eps in (savePath as alias) with options {compatibility:Illustrator 10, compressed:true, embed all fonts:true, PDF compatible:true}
close current document saving no
end repeat
end tell
Mike,
Couldn’t agree more. That’s what I get for being in a hurry! :rolleyes:
How do you feel about moving the assignment of the new save location outside the try block, assuming that it fails only if the “converted” folder already exists?
try
make new folder in sourceFolder with properties {name:"converted"}
end try
set targetPath to (sourceFolder as string) & "converted:"