Recursively batch-resave Illustrator AI files to legacy format

I need to downsave a few hundred AI files from AI CC to CS6. They are scattered across dozens of folders and I need a way to recursively overwrite the AI CC files with CS6 compatible files.

I researched and tried a few solutions, but none of them fits the bill.

Optimally this should be a reusable .jsx script, but if there’s another way to do this somehow through OS X’s Finder (savedSearch), that would be good, too.

Thanks in advance for all your help.

PS: Two scripts I found which more or less do what I need. Tried to make a Frankenscript out of parts of both, but no success, yet.

Script one

Script two


Since it wasn’t complicated, I decided to write it from scratch. I wouldn’t expect the script to be very fast, due to the fact that it’s opening, saving and closing files. It should highly depend on your computer and the .ai file(s) in question.

Make sure to check the first two variables: overwrite and targetVersion, before trying to run the script. You may also want to check the SaveOptions_ai function to further adjust the save settings

Illustrator convert to legacy.jsx

As always, use at your own risk. Especially with the overwrite option on, this is extremely destructive script and can render your files unusable, if you save it with low enough file version.
If you want to use overwrite, I’d suggest you duplicate the parent folder before running the script.

// Illustrator convert to legacy.jsx

// Finds all .ai files from the input folder + its subfolders and converts them to the version given below in a variable called "targetVersion"

// Tested in Illustrator cc 2014 (Mac)
// Didn't bother to do a speed test with my macbook air...

#target illustrator

    // If set to false, a new file will be written next to the original file.
    // The new file will have (legacyFile) in the name.
    // Files with (legacyFile) in the file name are always ignored.
var overwrite = true, // boolean
    // Accepted values:
    // 8, 9, 10, 11 (cs), 12 (cs2), 13 (cs3), 14 (cs4), 15 (cs5), 16 (cs6), 17 (cc)
    targetVersion = 13;

if ( app.documents.length > 0 ) {

    alert("ERROR: \n Close all documents before running this script." );

// Run the script
else {

    var files,
        folder = Folder.selectDialog("Input folder...");

    // If folder variable return null, user most likely canceled the dialog or
    // the input folder and it subfolders don't contain any .ai files.
    if ( folder != null ) {

        // returns an array of file paths in the selected folder.
        files = GetFiles( folder );

        // This is where things actually start happening...
        process( files );



function process( files ) {

    // Loop through the list of .ai files:
    // Open > Save > Close > LOOP
    for ( i = 0; i < files.length; i++ ) {

        // Current file
        var file = files[i]

        // Open file );

        // If overwrite is false, create a new file, otherwise use "file" variable;
        file = !overwrite ? new File( file.toString().replace(".ai", " (legacyFile).ai") ) : file;

        // Save
        app.activeDocument.saveAs( file, SaveOptions_ai() )

        // Close
        app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );


    // For better of for worse...
    alert( "Script is done." );


function SaveOptions_ai() {

    var saveOptions = new IllustratorSaveOptions();

    saveOptions.compatibility = Compatibility[ "ILLUSTRATOR" + targetVersion ];
    saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
    saveOptions.compressed = true; // Version 10 or later
    saveOptions.pdfCompatible = true; // Version 10 or later
    saveOptions.embedICCProfile = true; // Version 9 or later
    saveOptions.embedLinkedFiles = false; // Version 7 or later

    return saveOptions


function GetFiles( folder ) {

    var i, item,
        // Array to store the files in...
        files = [],
        // Get files...
        items = folder.getFiles();

    // Loop through all files in the given folder
    for ( i = 0; i < items.length; i++ ) {

        item = items[i];

        // Find .ai files
        var fileformat =\.ai$/i),
            legacyFile ="(legacyFile)") > 0;

        // If item is a folder, check the folder for files.
        if ( item instanceof Folder ) {

            // Combine existing array with files found in the folder
            files = files.concat( GetFiles( item ) );

        // If the item is a file, push it to the array.
        else if ( item instanceof File && fileformat && !legacyFile ) {

            // Push files to the array
            files.push( item );


    return files;

Source : Link , Question Author : Marco , Answer Author : Joonas

Leave a Comment