Skip to main content
Participant
June 24, 2020
Question

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

  • June 24, 2020
  • 1 reply
  • 1052 views

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 )

 

This topic has been closed for replies.

1 reply

Inspiring
June 24, 2020

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

Participant
June 24, 2020

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

 

Inspiring
June 25, 2020

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" )