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

changing eps to ai automatically by a script

New Here ,
Jun 05, 2020 Jun 05, 2020

can you help me for changing eps to ai automatically by a script . I have a tons of Eps and need this 🙂

TOPICS
Import and export , Scripting
5.1K
Translate
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 , Jun 05, 2020 Jun 05, 2020

Try the following code. This code was modified from the original source by Loic_Aigon in the thread mentioned below

https://community.adobe.com/t5/illustrator/batch-convert-ai-to-eps-including-subfolders/td-p/9746062?page=1

//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
...
Translate
Community Expert ,
Jun 05, 2020 Jun 05, 2020

Try the following code. This code was modified from the original source by Loic_Aigon in the thread mentioned below

https://community.adobe.com/t5/illustrator/batch-convert-ai-to-eps-including-subfolders/td-p/9746062...

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

 

Translate
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 16, 2023 Apr 16, 2023

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

Translate
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 Beginner ,
Dec 04, 2024 Dec 04, 2024

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

 

Translate
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 ,
Dec 18, 2024 Dec 18, 2024

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.

Translate
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 Beginner ,
Dec 19, 2024 Dec 19, 2024

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.

Translate
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 ,
Dec 19, 2024 Dec 19, 2024
Awesome! Works fine. There was only one issue when running and I’m sure it
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!
Translate
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 Beginner ,
Dec 22, 2024 Dec 22, 2024

Hey there! I’m glad it works. Could you please share the AI file with me so I can test it out?

Translate
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 ,
Dec 23, 2024 Dec 23, 2024
LATEST
Wish i could find the offending .eps file but wasn’t able to. If I hapen to
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.
Translate
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
Contributor ,
Jul 15, 2023 Jul 15, 2023

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.


scr_AI_Script.pngexpand image

 

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)

Translate
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 30, 2020 May 30, 2020

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

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

This same question has been posted on the following thread

https://community.adobe.com/t5/illustrator/changing-eps-to-ai-automatically-by-a-script/m-p/11185071...

I have answered it on the other thread. So i will lock this thread.

 

-Manan

Translate
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