Answered
changing eps to ai automatically by a script
can you help me for changing eps to ai automatically by a script . I have a tons of Eps and need this 🙂
can you help me for changing eps to ai automatically by a script . I have a tons of Eps and need this 🙂
Try the following code. This code was modified from the original source by Loic_Aigon in the thread mentioned below
//Some utils to retrieve files in folders and subfolders
var api = {
getFiles : function ( fo, aExtensions, bRecursive, aFiles, includeFolder )
{
var exts = aExtensions? aExtensions.join("|") : ".+" ;
var pattern = new RegExp ( "\\.("+exts+")$");
!aFiles && aFiles = [];
var filterFunction = function(file)
{
return pattern.test ( file.name );
}
if ( bRecursive && fo.name.indexOf ( ".")!=0 )
{
var foFiles = fo.getFiles();
while ( f = foFiles.shift() )
{
if ( f instanceof Folder )
{
if (includeFolder===true) files[ files.length ] = f;
this.getFiles ( f, aExtensions, true, aFiles );
}
if ( f instanceof File && pattern.test ( f.name ) && f.name!=".DS_Store" ) {
aFiles[ aFiles.length ] = f;
}
}
return aFiles;
}
else
{
return fo.getFiles ( filterFunction );
}
},
}
//Main routine
var main = function() {
var fo = Folder.selectDialog("Please select a folder"),
files, n = 0, doc, nFile,
opts = new IllustratorSaveOptions();
//Settings options
// opts.… = …
//Exit if no selected folder
if ( !fo ) return;
//getting AI files
files = api.getFiles ( fo, ["eps"], true );
n = files.length;
//Exit if no files found
if ( !n ) {
alert( "No files found sorry" );
return;
}
//convert found files
while ( n-- ) {
nFile = files[n];
doc = app.open ( nFile );
doc.saveAs ( File ( nFile.parent+"/"+nFile.name.replace ( /\.eps$/, '.ai' ) ), opts );
doc.close();
}
}
//run
main();
-Manan
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.