Skip to content

Instantly share code, notes, and snippets.

@kostimarko
Created March 14, 2019 14:49
Show Gist options
  • Save kostimarko/824078cf8853036e9a75cda980e4efb5 to your computer and use it in GitHub Desktop.
Save kostimarko/824078cf8853036e9a75cda980e4efb5 to your computer and use it in GitHub Desktop.
This script errors during foreach while using illustrator
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