Created
March 19, 2013 10:28
-
-
Save a1phanumeric/5195080 to your computer and use it in GitHub Desktop.
ESTK .jsx script to open directory of .ai files and save them as SVGs with standardised artboards (an artboard which perfectly fits the image).
This file contains hidden or 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
#target illustrator | |
var sourceDir, | |
destDir, | |
files, | |
sourceDoc; | |
sourceDir = Folder.selectDialog( 'Select the import directory.', '~' ); | |
destDir = Folder.selectDialog( 'Select the export directory.', sourceDir.sourceDir ); | |
files = sourceDir.getFiles("*.ai"); | |
if(files.length == 0){ | |
alert("No files to import"); | |
}else{ | |
for(i=0; i < files.length; i++){ | |
sourceDoc = app.open(files[i]); | |
// Create new filename | |
var ext = '.svg'; | |
var newName = ""; | |
var dot = files[i].name.lastIndexOf('.'); | |
newName += files[i].name.substring(0, dot); | |
newName += ext; | |
targetFile = new File( destDir + '/' + newName ); | |
// Resize artboard | |
app.activeDocument.artboards[0].artboardRect = app.activeDocument.visibleBounds; | |
redraw(); | |
// Export as SVG | |
var opt = new ExportOptionsSVG(); | |
sourceDoc.exportFile(targetFile, ExportType.SVG, opt); | |
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); | |
sourceDoc = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment