Created
March 14, 2019 14:49
-
-
Save kostimarko/824078cf8853036e9a75cda980e4efb5 to your computer and use it in GitHub Desktop.
This script errors during foreach while using illustrator
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, epsSaveOpts, doc; | |
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to png', '~' ); | |
if ( sourceFolder != null ) | |
{ | |
files = new Array(); | |
fileType = "*.ai"; | |
files = sourceFolder.getFiles( fileType ); | |
if ( files.length > 0 ) | |
{ | |
destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted png files.', '~' ); | |
for ( i = 0; i < files.length; i++ ) | |
{ | |
sourceDoc = app.open(files[i]); // returns the document object | |
doc = app.activeDocument; | |
doc.layers.forEach((layer)=>{ | |
doc.layers[layer].visible=true; | |
}) | |
} | |
alert( 'Files are saved as EPS in ' + destFolder ); | |
} | |
else | |
{ | |
alert( 'No matching files found' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment