Copy link to clipboard
Copied
can you help me for changing eps to ai automatically by a script . I have a tons of Eps and need this 🙂
1 Correct answer
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+")$");
!aFile
...
Explore related tutorials & articles
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
This script looks for *.EPS files and converts them to *.Ai ...
Everything OK.
It would be possible to implement after the file conversion, if the conversion was successful and in the folder where you got the EPS, do a comparison, if there is a file myfile.eps & myfile.ai, remove the EPS file.
----------------------
//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();
Copy link to clipboard
Copied
I came across this while searching for similar solutions. Anyway, I added a few scripts to prompt the user to select whether they want to delete the original .eps files after all convert are complete.
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) aFiles[aFiles.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);
}
},
deleteFiles: function (files) {
for (var i = 0; i < files.length; i++) {
files[i].remove();
}
},
};
// 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();
}
// Ask if the user wants to delete the original .eps files
if (confirm('Do you want to delete the original .eps files?')) {
api.deleteFiles(files);
}
};
// Run
main();
Copy link to clipboard
Copied
What scripting format is this in? I tried saving it as a .jsx and also as a .vbs but both ran an eror on line 7. That's as far as I got.
Copy link to clipboard
Copied
Umm. I've uploaded the jsx file for you to download.
https://file.io/zYIbS1GGjfHU
I'm running Illustrator 29. 1| on macOS Sequoia 15.2. Just run it again and it works fine on me.
Copy link to clipboard
Copied
can be updated, and that is when encountering an error I.e. a file fails to
convert for some reason the process stops. If there can be a prompt to skip
a problem file and continue that would be nice! Thanks for the script!
Copy link to clipboard
Copied
Hey there! I’m glad it works. Could you please share the AI file with me so I can test it out?
Copy link to clipboard
Copied
run into the same error next time the script is run I’ll be sure to keep
track of the file it had trouble with.
Copy link to clipboard
Copied
This script works a treat in 27.7 so thank you very much 🙂 I am new to scripting and still learning but... where would I invoke (see screenshot) into your script.
I want to set it to false so that it unchecks 'Create PDF Compatible File' while saving/converting but I am unsure where to add this into your script
OR...
is there a setting/option to set “Create PDF compatible file” OFF as the DEFAULT? I've looked through Preferences but maybe I missed it. Thank you in advance 🙂
(Screenshot from https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions.html)
Copy link to clipboard
Copied
Hi guys
I need a way ( or script ) for convert EPS files to Ai ( i cant and dont want to use save as !)
basicly I have a lot of eps files that I need change them to ai format.
when I want to use the actions ( first and easily way ) , I should record an example for illustrator but after saving the file to a directory for changing to AI , THE DIRECTORY THAT I USED FOR EXAMPLE IS SAVED ON 'ACTION' , so for next EPS file it saves that to that directory that was on example . I want a way for export them to ai and each eps file from a folder should save to same folder
Can you help me ?!
TNX
Copy link to clipboard
Copied
This same question has been posted on the following thread
I have answered it on the other thread. So i will lock this thread.
-Manan

