Highlighted

changing eps to ai automatically by a script

New Here ,
Jun 05, 2020

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 🙂

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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+")$");
			   !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

 

TOPICS
Import and export, Scripting

Views

343

Likes

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

changing eps to ai automatically by a script

New Here ,
Jun 05, 2020

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 🙂

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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+")$");
			   !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

 

TOPICS
Import and export, Scripting

Views

344

Likes

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

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

Likes

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
Reply
Loading...
May 30, 2020 0
Adobe Community Professional ,
Jun 05, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jun 05, 2020 0
Adobe Community Professional ,
Jun 05, 2020

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

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

 

Likes

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
Reply
Loading...
Jun 05, 2020 0