Highlighted

illustrator is saving the file under a new name everytime i hit 'save'

New Here ,
Jun 24, 2020

Copy link to clipboard

Copied

How can i let illustrator save the file under a new name everytime i hit 'save'

the output should be 

FileName___1.ai (version 1 )

FileName___2.ai (version 2 )

FileName___3.ai (version 3 )

 

TOPICS
Import and export, Print and publish, Scripting

Views

94

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

illustrator is saving the file under a new name everytime i hit 'save'

New Here ,
Jun 24, 2020

Copy link to clipboard

Copied

How can i let illustrator save the file under a new name everytime i hit 'save'

the output should be 

FileName___1.ai (version 1 )

FileName___2.ai (version 2 )

FileName___3.ai (version 3 )

 

TOPICS
Import and export, Print and publish, Scripting

Views

95

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 24, 2020 0
Community Beginner ,
Jun 24, 2020

Copy link to clipboard

Copied

Hi, I don't think it's possible to override the default save feature, but you can certainly create a script to do this. I'm going to use JS since that's my go-to.

 

The method you're looking for is saveAs() in the Document object. It takes the full path & file name as its parameter.

 

activeDocument.saveAs( Folder.myDocuments + "/FileName___1.ai" )

 

 The other part of this algorithm is making that version number dynamic. Your exact methodology may differ, but I would check how many files with a similar name exist in the directory.

 

var len = Folder.myDocuments.getByName( "FileName___*.ai" ).length + 1 || 1
activeDocument.saveAs( Folder.myDocuments + "/FileName___" + len + ".ai" )

 

 The first line assigns the number to len, and the second line inserts len into the new file name we're saving.

I used the My Documents folder, but you can use any directory you want in its place.

len has a contingency with the or operator (||) but you may find you need to use a try-catch statement to avoid an error when no files get returned by getByName().

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

Copy link to clipboard

Copied

hello, thank you for the answer. it's helpful however when i tried to execute the js code inside illustrator, i receive such error .

Can you help? thanks

abahmedudp_0-1593029983083.png

 

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 24, 2020 1
Community Beginner ,
Jun 24, 2020

Copy link to clipboard

Copied

Yep, you need to add that try-catch I mentioned.

Like this:

try {
  var len = Folder.myDocuments.getByName( "FileName___*.ai" ).length + 1
} catch( e ) {
  var len = 1
}
activeDocument.saveAs( Folder.myDocuments + "/FileName___" + len + ".ai" )

 

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 24, 2020 1