Skip to content

Instantly share code, notes, and snippets.

@walpolea
Last active September 1, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walpolea/c80ef42188bd90af34683d6513d13e7b to your computer and use it in GitHub Desktop.
Save walpolea/c80ef42188bd90af34683d6513d13e7b to your computer and use it in GitHub Desktop.
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile;
// Select the source folder.
sourceFolder = Folder.selectDialog("Select the folder with EPS files you want to convert to SVG", "~");
// If a valid folder is selected
if (sourceFolder != null) {
files = new Array();
fileType = "*.eps";
files = sourceFolder.getFiles(fileType);
if (files.length > 0) {
destFolder = Folder.selectDialog("Select the folder where you want to save the converted SVG files.", "~");
processFiles(files);
} else {
alert("No matching files found");
}
}
function processFiles(files) {
if (files.length) {
var file = files.shift();
sourceDoc = app.open(file);
targetFile = new File(destFolder + "/" + sourceDoc.name.split(".")[0] + ".svg");
var options = new ExportOptionsSVG();
sourceDoc.exportFile(targetFile, ExportType.SVG, options);
sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
processFiles(files);
} else {
alert("Files are saved as UNCOMPRESSED SVG in " + destFolder);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment