Skip to content

Instantly share code, notes, and snippets.

@jasonm23
Created May 5, 2010 22:37
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 jasonm23/391556 to your computer and use it in GitHub Desktop.
Save jasonm23/391556 to your computer and use it in GitHub Desktop.
Export folder of AI's to PNG (choose input/output folder)
/**
* Illustrator script.
* Export folder of AI's to PNG (choose input/output folder)
*
*
* @author Jason Milkins - mentalaxis.com
*/
var folder = Folder.selectDialog('Select folder with illustrator files...');
var pngFolder = Folder.selectDialog('Select folder for png export...');
if (folder)
{
var fileList = folder.getFiles();
for (var i=0; i < fileList.length; i++)
{
if(fileList[i] instanceof File)
{
var file = fileList[i];
var fname = file.name.toLowerCase();
if(fname.indexOf('.ai') != -1)
{
app.open (file);
var document = app.activeDocument;
var options = new ExportOptionsPNG24();
options.antiAliasing = true;
options.transparency = true;
options.artBoardClipping = true;
var pngName = document.name.substring(0, document.name.indexOf(".ai"));
var pngFile = new File(pngFolder.fsName+"/"+pngName+".png");
document.exportFile (pngFile, ExportType.PNG24, options);
document.close (SaveOptions.DONOTSAVECHANGES);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment