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

Batch convert .ai to .eps including subfolders

New Here ,
Apr 09, 2018 Apr 09, 2018

Copy link to clipboard

Copied

I have a ton of .ai files(1000+), in folders, that I want to copy/convert to .eps files. I am trying to figure out a script but do not know enough about it to do it. Anyone know of an easy way to do this?

Thanks

Cheryl

TOPICS
Scripting

Views

4.2K

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

People's Champ , Apr 10, 2018 Apr 10, 2018

//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[

...

Votes

Translate

Translate
Adobe
New Here ,
Apr 09, 2018 Apr 09, 2018

Copy link to clipboard

Copied

I am using CS6.

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
People's Champ ,
Apr 10, 2018 Apr 10, 2018

Copy link to clipboard

Copied

//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 EPSSaveOptions();

//Settings options

// opts.… = …

//Exit if no selected folder

if ( !fo ) return;

//getting AI files

files = api.getFiles ( fo, ["ai"], true );

n = files.length;

//Exit if no files found

if ( !n ) {

alert( "No files found sorry" );

return;

}

//convert found files

while ( n-- ) {

nFile = files;

doc = app.open ( files );

doc.saveAs ( File ( nFile.parent+"/"+nFile.name.replace ( /\.ai$/, '.eps' ) ), opts );

doc.close();

}

}

//run

main();

HTH

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
New Here ,
Aug 07, 2018 Aug 07, 2018

Copy link to clipboard

Copied

Loic.Aigon ,

I've read tutorial after tutorial and can't seem to wrap my head around scripting for Illustrator. I'm looking to do just the opposite of what the OP wanted to do, I need to convert folders full of EPS files back to AI. If I were to switch those references around in the script you have provided would that work? If not, I don't want to bother you any further, just hoping it would be as easy as I'm speculating it to be.

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
Valorous Hero ,
Aug 07, 2018 Aug 07, 2018

Copy link to clipboard

Copied

You will have to change the save options to be the Illustrator ones (l.47) and the save-as file object to replace the eps with ai instead of how it is now (l.70).

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
New Here ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

sorry i wanna post a question about converting the eps to ai file , that i saw this post.can you help me for this?

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
Advocate ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

Bonjou dr_rapide

Si tu veux faire l'inverse eps vers ai, tu remplaces la fin du script de Loïc à partir de la ligne 33

par

 

//Main routine  ligne 33
  var main = function() {
    var fo = Folder.selectDialog("Please select a folder"),
    files, n = 0, doc, nFile;
    //Settings options
    // Options pour l’enregistrement d’un document au format Illustrator.
  var opts  = new IllustratorSaveOptions();
  // opts.… = …
    //Exit if no selected folder
      if ( !fo ) return;
    //getting AI files
      files = api.getFiles ( fo, ["eps"], true );    // alert(files)
      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 ( files[n] );
        doc.saveAs ( File ( nFile.parent+"/"+nFile.name.replace ( /\.eps$/, '.ai' ) ), opts );
        doc.close();
      }
}
//run
main();

 

restera si besoin à définir les options autres que par défaut

ligne  //opts. ... = ....

de elleere

 

 

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
New Here ,
Jun 05, 2020 Jun 05, 2020

Copy link to clipboard

Copied

tnx a lot .

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 ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

Hi Loic_Aigon,

Thanks for your answer! Would you mind explaining a line to me please?

!aFiles && aFiles =[];

 This line causes my linter to complain. Is it functionally the same as writing:

if (!aFiles) aFiles = [];

Thanks,

Mark

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 ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

Yes, that's correct,. If aFiles does not declared, it goes to the second condition after && and declared aFiles as an array.

 

Best regards

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 ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

👍

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
New Here ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hi I am trying to use this script again but no on CC2021. Getting an error.error.jpg

 

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
New Here ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

I am also going from eps to ai now.

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
Advocate ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

Bonjour,

Il faut inclure le début du script de Loïc placé avant

//Main routine ligne 33

 

 

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
New Here ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

//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 EPSSaveOptions();

 

//Settings options

// opts.… = …

 

//Exit if no selected folder

if ( !fo ) return;

 

//getting AI files

files = api.getFiles ( fo, ["ai"], true );

n = files.length;

 

//Exit if no files found

if ( !n ) {

alert( "No files found sorry" );

return;

}

 

 

//convert found files

while ( n-- ) {

nFile = files;

doc = app.open ( files );

doc.saveAs ( File ( nFile.parent+"/"+nFile.name.replace ( /\.ai$/, '.eps' ) ), opts );

doc.close();

}

}

 

 

//run

main();

 

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
New Here ,
Feb 14, 2022 Feb 14, 2022

Copy link to clipboard

Copied

I am using this script to convert .ai to .eps files on the current version of CC and it has stopped working. Can anyone help? Please? Here is the erorr.

 

CherylC_0-1644853775696.png

 

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 ,
Feb 14, 2022 Feb 14, 2022

Copy link to clipboard

Copied

The text of the script has been slightly mangled, possibly by a forum re-vamp in the past. Here it is fixed up and tested on AI 2022 MacOS:

//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 + ")$");
        if (!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 EPSSaveOptions();

    //Settings options
    // opts.… = …

    //Exit if no selected folder
    if (!fo) return;

    //getting AI files
    files = api.getFiles(fo, ["ai"], 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(/\.ai$/, '.eps')), opts);
        doc.close();
    }
}


//run
main();

 

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
New Here ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

doesn't work 

Error 8: Errore di sintassi.
Line: 1
> {\rtf1\ansi\ansicpg1252\cocoartf2636

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 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

@Jeansevilla, your error is because you have saved the script as a rich text file (see the "rtf1" tag in the error message). You must save the script as a plain text file.

- Mark

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
Participant ,
Apr 21, 2023 Apr 21, 2023

Copy link to clipboard

Copied

I am using this script to convert all EPS files, to AI.
The script works fine, I just want to:

1. when opening an error file the script continues to process the other files

2. when the MISSING FONT window appears, the window can be closed by itself and to put the conversion operation in AI (even without the font)

3. when it gives me the CMYK required notice go ahead

4. which can suppress any window that requires manual Acceptance by the user.

5. Do you know any other script maybe better than this one?

---------- [ CODE ] -----------------

//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("Selezionare la cartella Sorgente! [eps, pdf, svg, ai ]"),
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", "ai", "pdf","svg"], true );

//files = api.getFiles ( fo, ["eps", "EPS", "ai", "AI"], true );
//files = api.getFiles ( fo, ["ai", "AI"], true );
files = api.getFiles ( fo, ["eps", "EPS"], true );

n = files.length;
//Exit if no files found
if ( !n ) {
alert( "Nessun file è stato trovato." );
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();

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
New Here ,
Nov 28, 2023 Nov 28, 2023

Copy link to clipboard

Copied

LATEST

Hi
Can someone post a step-by-step guide on how to action the script on Macosx please? I am completely lost!

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