Skip to content

Instantly share code, notes, and snippets.

@ondrejtichacek
Last active June 10, 2022 15:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ondrejtichacek/2bc3bf77f0e2003935f3cdf789738726 to your computer and use it in GitHub Desktop.
Save ondrejtichacek/2bc3bf77f0e2003935f3cdf789738726 to your computer and use it in GitHub Desktop.
Adobe Illustrator script for batch exporting eps files
// script.name = export-eps.js;
// script.description = opens and exports Ai files as EPS (Folder Batch);
// script.requirements = none
//
// based on:
// http://forums.adobe.com/thread/1224874?tstart=0
// https://stackoverflow.com/questions/16541273/illustrator-script-for-exporting-as-eps
//
// see EPSSaveOptions reference e.g. here:
// https://wwwimages2.adobe.com/content/dam/acom/en/devnet/illustrator/pdf/Illustrator_Scripting_Reference_JavaScript_2015.pdf
var extension = ".ai";
if (app.documents.length > 0) {
var folder = Folder(app.activeDocument.path).selectDlg("Select Source Folder...");
}
else {
var folder = Folder.selectDialog("Select Source Folder...\nHint: Open a document to set default path"); // select folder
}
if (folder==null) {
alert("Good Bye");
}
else {
var files = find_files (folder, [extension]);
var fileCount = files.length; // count them
if (fileCount>0) {
for (i=0; i<fileCount; i++) {
var idoc = app.open(files[i]);
var saveOpts = new EPSSaveOptions();
saveOpts.cmykPostScript = true;
saveOpts.compatibility = Compatibility.ILLUSTRATOR16;
saveOpts.embedAllFonts = false;
saveOpts.embedLinkedFiles = false;
saveOpts.includeDocumentThumbnails = false;
saveOpts.postScript = EPSPostScriptLevelEnum.LEVEL3;
saveOpts.preview = EPSPreview.None;
saveOpts.saveMultipleArtboards = false;
idoc.saveAs( files[i], saveOpts );
idoc.close();
}
alert(fileCount + ' file(s) processed');
}
else {
alert("There are no Illustrator " + extension + " files in this folder.");
}
}
// recurse subfolders - Peter Kharel
function find_files (dir, mask_array){
var arr = [];
for (var i = 0; i < mask_array.length; i++){
arr = arr.concat (find_files_sub (dir, [], mask_array[i].toUpperCase()));
}
return arr;
}
function find_files_sub (dir, array, mask){
var f = Folder (dir).getFiles ( '*.*' );
for (var i = 0; i < f.length; i++){
if (f[i] instanceof Folder){
find_files_sub (f[i], array, mask);
} else if (f[i].name.substr (-mask.length).toUpperCase() == mask){
array.push (f[i]);
}
}
return array;
}
@Nprod17
Copy link

Nprod17 commented Apr 3, 2019

This is a great script for creating eps with embedded fonts and art (I switched to "true" for Lines 32 & 34). There is a typo in Line 12. The double quotes around file type should be single.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment