Skip to main content
Participant
March 11, 2009
Question

Batch Export as PNG

  • March 11, 2009
  • 9 replies
  • 56068 views
Hello, i'm having dreadful trouble exporting a batch of AIs to PNG (using illustrator CS4).

It seemed really obvious to record export>PNG>relevant setting as an action and then run that on the whole folder.

The trouble is that the action, when run as a batch (and only when run as a batch) skips the whole export step. it open the AI fine, runs through the action very quickly, and then fails to write the PNG.

what's more, i also tried this on a colleagues machine and his did exactly the same, so i'm thinking that it's me missing something obvious.

as a workaround i turned the dialogues on, but this kind of defeats the object.

any help would be very greatly appreciated.

cheers
Jez
    This topic has been closed for replies.

    9 replies

    Participant
    February 28, 2018

    Hi Guys,

    This script worked for me. I am running Adobe Illustrator CC and found this script by Export Illustrator Layers and/or Artboards as PNGs and PDFs | Matthew Ericson - ericson.net

    To use the script, download MultiExporter.jsx and put in your Illustrator scripts folder (usually in Applications/Adobe Illustrator/Presets/Scripts/). Restart Illustrator, and run the script by going to “File > Scripts > MultiExporter”.

    Here's the trick.

    Once installed, Start Illustrator, and open up the file with the multiple Artboards.  Go to the Artboards TAB and change the artboard names to something else, I named mines LOGO

    More notes..

    You can choose whether you want to export all the artboards in the document with the currently visible layers showing, or if you want to export files for each of the layers in a document on the currently active artboard, or if you want to export a combination of all the artboards multiplied by all the layers.

    • Files are named based on their layer name. It only exports layers where their name has been changed from the default “Layer 1″, “Layer 2″ or “Artboard 1”, “Artboard 2”, etc.
    • If you put a minus sign  in front of a layer name or artboard name, it will skip that layer or artboard. (Useful for when you no longer decide you like a particular mockup, but don’t want to delete it from the master Illustrator document.)
    • For layers only: If you put a plus sign  in front of a layer name, that layer will always be visible. Useful for if you want to have a layer that always appears in the background of each exported image.
    • It stores its settings in a nonvisible, nonprinting layer named “nyt_exporter_info”
    • It has an option for transparency, and lets you choose between PNG8, PNG24 and PDF.
    Participant
    July 20, 2016

    Hi,

    When I select the script it lets me select a folder, but then it asks me what type of file. What do i put here? I typed in .ai, but then it says it can't find that file.

    Larry G. Schneider
    Community Expert
    Community Expert
    July 20, 2016

    Try using *.ai. The asterisk is a wild card for "any file".

    Participant
    July 20, 2016

    Larry,

    I tried that

    Participating Frequently
    October 7, 2015

    This is great. I don't understand the problem. thanks to Larry G. Schneider

    Copy tekst below. Open the program 'extendedScript Toolkit' (in Adobe Utilities), past it and save 'yourScript' into (Illustrator Folder> Presets>Scripts). Restart AI. Open AI and with no file opened go to >File >Scripts > and run 'yourScript'.

    The script asks you to 'Choose Folder'. Then, 'select type of illustrator files you want to process'. Then fill in '*.ai' (don't forget that asterisk and the dot before ai, or eps). Then 'Choose -destination Folder'. Done an Run

    /**********************************************************

    ADOBE SYSTEMS INCORPORATED

    Copyright 2015 Adobe Systems Incorporated

    All Rights Reserved

    NOTICE:  Adobe permits you to use, modify, and

    distribute this file in accordance with the terms

    of the Adobe license agreement accompanying it. 

    If you have received this file from a source

    other than Adobe, then your use, modification,

    or distribution of it requires the prior

    written permission of Adobe.

    *********************************************************/

    /**********************************************************

    ExportDocsAsPNG24fromFolder.jsx

    DESCRIPTION

    This sample gets files specified by the user from the

    selected folder and batch processes them and saves them

    as PNGs in the user desired destination with the same

    file name.

    **********************************************************/

    // Main Code [Execution of script begins here]

    // uncomment to suppress Illustrator warning dialogs

    // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pngExportOpts;

    // Select the source folder.

    sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );

    // If a valid folder is selected

    if ( sourceFolder != null )

    {

        files = new Array();

        fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );

       

        // Get all files matching the pattern

        files = sourceFolder.getFiles( fileType );

       

        if ( files.length > 0 )

        {

            // Get the destination to save the files

            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); // returns the document object

                                       

                // Call function getNewName to get the name and file to save the png

                targetFile = getNewName();

               

                // Call function getPNGOptions get the PNGExportOptions for the files

                pngExportOpts = getPNGOptions();

               

                // Export as PNG

                sourceDoc.exportFile( targetFile, ExportType.PNG24, pngExportOpts );

               

                sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

            }

            alert( 'Files are saved as PNG in ' + destFolder );

        }

        else

        {

            alert( 'No matching files found' );

        }

    }

    /*********************************************************

    getNewName: Function to get the new file name. The primary

    name is the same as the source file.

    **********************************************************/

    function getNewName()

    {

        var ext, docName, newName, saveInFile, docName;

        docName = sourceDoc.name;

        ext = '.png'; // new extension for png file

        newName = "";

           

        for ( var i = 0 ; docName != "." ; i++ )

        {

            newName += docName;

        }

        newName += ext; // full png name of the file

       

        // Create a file object to save the png

        saveInFile = new File( destFolder + '/' + newName );

        return saveInFile;

    }

    /*********************************************************

    getPNGOptions: Function to set the PNG saving options of the

    files using the PNGSaveOptions object.

    **********************************************************/

    function getPNGOptions()

    {

       

        // Create the PNGSaveOptions object to set the PNG options

        var pngExportOpts = new ExportOptionsPNG24();

       

       

       

        // Setting PNGExportOptions properties. Please see the JavaScript Reference

        // for a description of these properties.

        // Add more properties here if you like

        pngExportOpts.antiAliasing = true;

        pngExportOpts.artBoardClipping = false;

        //pngExportOpts.horizontalScale = 100.0;

        //pngExportOpts.matte = true;

        //pngExportOpts.matteColor = 0, 0, 0;

        pngExportOpts.saveAsHTML = false;

        pngExportOpts.transparency = true;

        //pngExportOpts.verticalScale = 100.0;

        return pngExportOpts;

    }

    Participating Frequently
    November 10, 2015

    Thanks!

    AroeiraVermelha
    Participant
    March 31, 2010

    Here is a another option w/ Acrobat Professional:

    1. File > Combine > Merge Files into a Single PDF
    2. Add Files > Select your Illustrator files (yes, *.ai )
    3. Combine Files (bottom right corner)
    4. Save your PDF

    Now you have this PDF file where each page is one of those AI files you want to batch convert to a medium/high-res PNG.

    1. File > Export > Image > PNG
    2. Settings <- important! (it's next to the format drop down menu at the bottom of the dialogue box)
    3. You can type the target resolution or select from the options available
    4. OK
    5. Save
    Participant
    January 8, 2020

    After I've created the Acrobat Portfolio file containing the 80+ AI files, all of the graphic file options (File>Export>Image>...PNG) is grayed out.

    Suggestions???

    January 29, 2010

    You've probably already found a work around since this post was back in March - but for future people who have just run into the same issue/bug (as *I* just did) - I've accomplished the goal of going from Illustrator EPS > PNG by creating a batch action to export to PSD as a first step - and then a second action (in photoshop) to go from PSD > PNG. 

    It's an extra step, but much faster than doing each file individually.

    Participating Frequently
    May 8, 2009

    Has anyone been able to figure out a solution to this. I have about 200 logos that I need to export as PNG files, and I REALLY don't want to have to do this one by one. Any advice would be MUCH appreciated.

    Thanks!

    Larry G. Schneider
    Community Expert
    Community Expert
    May 8, 2009

    You might try this

    /**********************************************************

    ADOBE SYSTEMS INCORPORATED
    Copyright 2005 Adobe Systems Incorporated
    All Rights Reserved

    NOTICE:  Adobe permits you to use, modify, and
    distribute this file in accordance with the terms
    of the Adobe license agreement accompanying it. 
    If you have received this file from a source
    other than Adobe, then your use, modification,
    or distribution of it requires the prior
    written permission of Adobe.

    *********************************************************/

    /**********************************************************

    ExportDocsAsPNG24.jsx

    DESCRIPTION

    This sample gets files specified by the user from the
    selected folder and batch processes them and saves them
    as PDFs in the user desired destination with the same
    file name.

    **********************************************************/

    // Main Code [Execution of script begins here]

    // uncomment to suppress Illustrator warning dialogs
    // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, pngExportOpts;

    // Select the source folder.
    sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );

    // If a valid folder is selected
    if ( sourceFolder != null )
    {
        files = new Array();
        fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
       
        // Get all files matching the pattern
        files = sourceFolder.getFiles( fileType );
       
        if ( files.length > 0 )
        {
            // Get the destination to save the files
            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); // returns the document object
                                       
                // Call function getNewName to get the name and file to save the pdf
                targetFile = getNewName();
               
                // Call function getPNGOptions get the PNGExportOptions for the files
                pngExportOpts = getPNGOptions();
               
                // Export as PNG
                sourceDoc.exportFile( targetFile, ExportType.PNG24, pngExportOpts );
               
                sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
            }
            alert( 'Files are saved as PNG in ' + destFolder );
        }
        else
        {
            alert( 'No matching files found' );
        }
    }


    /*********************************************************

    getNewName: Function to get the new file name. The primary
    name is the same as the source file.

    **********************************************************/

    function getNewName()
    {
        var ext, docName, newName, saveInFile, docName;
        docName = sourceDoc.name;
        ext = '.png'; // new extension for png file
        newName = "";
           
        for ( var i = 0 ; docName != "." ; i++ )
        {
            newName += docName;
        }
        newName += ext; // full png name of the file
       
        // Create a file object to save the png
        saveInFile = new File( destFolder + '/' + newName );

        return saveInFile;
    }


    /*********************************************************

    getPNGOptions: Function to set the PNG saving options of the
    files using the PDFSaveOptions object.

    **********************************************************/

    function getPNGOptions()
    {
       
        // Create the PDFSaveOptions object to set the PDF options
        var pngExportOpts = new ExportOptionsPNG24();
       
       
       
        // Setting PNGExportOptions properties. Please see the JavaScript Reference
        // for a description of these properties.
        // Add more properties here if you like
        pngExportOpts.antiAliasing = true;
        pngExportOpts.artBoardClipping = false;
        //pngExportOpts.horizontalScale = 100.0;
        //pngExportOpts.matte = true;
        //pngExportOpts.matteColor = 0, 0, 0;
        pngExportOpts.saveAsHTML = false;
        pngExportOpts.transparency = true;
        //pngExportOpts.verticalScale = 100.0;

        return pngExportOpts;
    }

    Copy into a text editor and save as a .jsx file and place in the presets>scripts folder.

    Participating Frequently
    May 8, 2009

    Thanks, Larry.

    which segment of code do i need to copy?  I wasn't sure. Also, I pasted into text edit and Word....neither will let me save as a .jsx. Any suggestions?

    try67
    Community Expert
    Community Expert
    March 17, 2009
    It's probably possible to do this with a script. If you're interested, contact me by email.
    rcraighead
    Legend
    March 16, 2009
    Jez,

    I'm having the same problem. It skips the export action. I was able to make it work in CS3, but the files are CS4.

    Wade, thanks for your suggest. In this case that is not an option.
    Participating Frequently
    March 12, 2009
    Well I do not know the status of the art but if they could be place in one document on multiple artboards then the solution is easy you d o not need to batch a simple export allows you to export all the art boards and individual png files all in one export operation.