Last active
September 1, 2020 14:38
-
-
Save walpolea/c80ef42188bd90af34683d6513d13e7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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