• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to convert new EPS files to legacy (CS6 or earlier) AI files?

Explorer ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Hi all,

 

Novice user here. Just had my mind blow today when I discovered the concept of Illustrator scripts. I have no idea how to create or edit them, but I did manage to find one to download and try it and it worked. I have a ton of newer vector files that I've downloaded and can't open on my personal computer because it only has CS6. My work computer has CC22, but I'm talking like hundreds of files to convert. I found a script that worked to convert newer ai files to legacy ai files, now I just need one to convert newer eps files to legacy ai files. Below is the script I used to go from new ai to legacy ai. Does anyone know how to tweak it to go from new eps to legacy ai?

 

Any thoughts are much appreciated.

 

Here's the source: https://gist.github.com/joonaspaakko/df2f9e31bdb365a6e5df

 

Here's the script:

 

// https://gist.github.com/joonaspaakko/df2f9e31bdb365a6e5df

// 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
app.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 = item.name.match(/\.ai$/i),
legacyFile = item.name.indexOf("(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;
}

TOPICS
Scripting

Views

412

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 22, 2022 Mar 22, 2022

Basically you would need the script to open both eps and ai files right? then the script just continues saving the current file to legacy ai

 

change this line

var fileformat = item.name.match(/\.ai$/i),

to this

var fileformat = item.name.match(/\.(ai|eps)$/i),

 

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

Basically you would need the script to open both eps and ai files right? then the script just continues saving the current file to legacy ai

 

change this line

var fileformat = item.name.match(/\.ai$/i),

to this

var fileformat = item.name.match(/\.(ai|eps)$/i),

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

Yes, this is perfect, thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 23, 2022 Mar 23, 2022

Copy link to clipboard

Copied

LATEST

my pleasure, is your mind blown?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines