I realize this can probably be done very easily I am just overlooking something, however I have been trying my hand at this for the past few days and I’m out of ideas. My problem is this:
I have a large set (roughly 2,000) .ai ilustrator files that I need to convert to generic .eps and save in they’re current location. Each .ai file is organized in a set path that can not be modified.
Reading up on and using illustrator’s built in batch functionality it apears I could use it however per the instructions it says to create an action that includes a save to function and then close function. Set source directory and check ‘override action open & include all subdirectories’ and the destination file to none.
When I run this however it opens up all the files, converts them to eps but continually overwrites one another in the save-as directory I specified durring the “save-as” in the action.
If I select a destination folder in the batch window they export fine however I have lost the folder structure.
My question is this. Is there a way either within illustrator or via applescript to open a large set of ai files and re-save them as .eps while keeping the folder structure intact?
This is a quick handler which will save any “.ai” file within the same folder as EPS, with name “filename.ai.eps”. You can adaptate it to whatever you need:
to exportILL(alias_)
set AppleScript's text item delimiters to ":"
set filePath to (alias_ as text)'s text items
set folder_ to (items 1 thru -2 of filePath as text) & ":"
set file_ to item -1 of filePath
set AppleScript's text item delimiters to {""}
tell application "Adobe Illustrator 10"
open alias_
set epsOptions to ¬
{class:EPS save options, CMYK PostScript:true, embed all fonts:true, embed linked files:true, flatten output:preserve appearance, include document thumbnails:false, japanese file format:false, PostScript:level 3, preview:color TIFF}
save document 1 in file (folder_ & file_ & ".eps") as eps with options epsOptions
close document 1 saving no
end tell
end exportILL
Thanks for the script, however I am curious if there is a way to extend it to allow for recursive directories. (ie drag 1 folder containing all the files (including in subfolders) and have it save within those folders) Instead of manualy needing to drag each directory manually to the script. Also I do not need the original file - so if its possible to overwrite the .ai file as well (or delete it afterwards) that would be awesome.
Thank you again for your quick response. I am not applescript adept quite yet, however after this I think I’ll be picking up a book or two and reading up on it!
You can process any file/folder using this recursive routine:
on open aliasList
repeat with i in aliasList
processItem(i)
end repeat
end open
to processItem(thisItem)
if (thisItem as text) ends with ":" then
processFolder(thisItem)
else
processFile(thisItem)
end if
end processItem
to processFolder(thisFolder)
set itemList to list folder thisFolder without invisibles
repeat with i in itemList
processItem(alias ((thisFolder as text) & i))
end repeat
end processFolder
to processFile(thisFile)
--> do whatever you need with this file
end processFile
The “open” handler will receive a list of files/folders dropped onto your script application (called “droplet” when you can drag&drop files onto it), and it will recursivelly search for files, where you can add your own code.
So, in the “processFile” handler you can include any code you need to process a single file. Eg, substitute “–> do whatever you need” with “exportILL(thisFile)”
Oh! Remember include the “exportILL” handler into your script and save it as application!
Finally, you can add a last line in the “exportILL” handler or in the “processFile” handler, after you saved your “.ai” as “.eps”:
tell app "Finder" to delete thisFile
Or (i prefer this one):
do shell script "rm " & quoted form of posix path of thisFile
This is how I would do it. You can save this code as an application. Then either drag and drop your folder full of Illustrator files or double click the app and choose the folder that way.