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

Script : Save Illustrator CC to CS6

New Here ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Hello, I am really beginner in the use of scripts in illustrator so I try my luck here!

I'm looking for a batch action script that would save my Illustrator CC files to Illustrator CS6, with a suffix on the file name: "-CS6". This would give "date-name-version-CS6". How can I do this? Thank you for your answers !

TOPICS
Scripting

Views

1.8K

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
Adobe
Participant ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

Hey!

You can save the current document with something like this:

var doc = app.activeDocument;  // get a reference to the current active document

var filename = doc.fullName;   // get the full name and path of the file

filename = filename.substr( 0, filename.lastIndexOf( '.' ) );   // strip off the file ending, assumes that the filename has an extension at the end

filename += "-CS6.ai"   // append "-CS6" to the end of the name

var saveOpts = new IllustratorSaveOptions();

saveOpts.compatibility = Compatibility.ILLUSTRATOR16;  // specify AI version number

doc.saveAs( filename, saveOpts );   // save out the file to the new path with the specified save options

doc.close();  // close the file

You'll still need to loop through all the files, here's some documentation on loops.

Also! Note that this script assumes that the file will already have an extension, so it's "fullName" property would be something like

"~/Documents/myFile.ai"

in this case it has to strip the ".ai" off before it can add the "-CS6".  If it hasn't been saved yet, then I think you should be able to just comment out line 4.

Good luck!

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 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Whaouw, thanks ! I'll try your code asap !

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 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Capture.PNG

Apparently it doesn't work cause of an error line 4. The document has been already saved into CC version, is that the cause?

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 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

LATEST

Hi simon.chasseloup,

there are several ways to do this.

One simple way:

Replace this line

var filename = doc.fullName;   // get the full name and path of the file

with this

var filename = doc.fullName.toString();   // get the full name and path of the file 

--------------------------------------------------------------------

Or you can replace this part (of the code written by zertle​)

var filename = doc.fullName;   // get the full name and path of the file

filename = filename.substr( 0, filename.lastIndexOf( '.' ) );   // strip off the file ending, assumes that the filename has an extension at the end

filename += "-CS6.ai"   // append "-CS6" to the end of the name

with this part

var filename = doc.name;   // get the name of the file

var filepath = doc.path;   // get the path of the file

filename = filename.replace( /\.(ai)?$/, "-CS6.ai" );   // replace ".ai" with "-CS6.ai" at the end of the name

filename = filepath+"/"+filename; // set the full name and path of the file

Or, or, or …

Have fun

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