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

Change Illustrator version with scripting?

New Here ,
Sep 16, 2010 Sep 16, 2010

Hello!

I go through several dozen files a day at work and we have to save down everything to 9 as we go.


Actions don't seem to delve that deep into the save as promt, so how can I script this so that the default goes to Version Illustrator 9 everytime?

I'm looking to do a similar script while exporting my format as default jpeg instead of png.

Help anyone on where to point me?  I'm familiar with the basics of scripting.  It's been a while but I need a starting point on if this is even possible.

Thanks!

TOPICS
Scripting
2.6K
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
Adobe
Explorer ,
Sep 18, 2010 Sep 18, 2010

// Saves the current document to dest as an AI file with specified options,

// dest specifies the full path and file name of the new file

function exportFileToAI (dest) {

if ( app.documents.length > 0 ) {

var saveOptions = new IllustratorSaveOptions();

var ai9Doc = new File(dest);

saveOptions.compatibility = Compatibility.ILLUSTRATOR9;

saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;

app.activeDocument.saveAs( ai9Doc, saveOptions );

}

}

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 ,
Sep 21, 2010 Sep 21, 2010

Looks great but it doesn't seem to do anything.  I ran it, and the Applescript editor stated, "Syntax Error - Expeced end of line, etc. but found identifier and highlighted exportFileToAI.

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
Guide ,
Sep 21, 2010 Sep 21, 2010

The posted function is ExtendScript and NOT AppleScript. You really should state what OS you are using and which is your preferred scripting language. You could use it but you need to use ESTK and NOT Apple's Script Editor…

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 ,
Sep 21, 2010 Sep 21, 2010

Muppet Mark,

My apologies, I'm new at this and it didn't occur to me.  I'm on a Mac OSX 10.6.4 and using Illustrator CS4.  The last time I did scripting was C++ 5 years ago in college and some action scripting in Flash but that's the extent.  I'm a quick learner but I'm totally new to this and the saving script and jpeg seem a bit beyond at the moment.

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
Guide ,
Sep 21, 2010 Sep 21, 2010

No, worries NO need to apologize to me… Just a pointer to save people potentially wasting their time… You can use either AppleScript or ExtendScript on your OS. Do you want more or less the sample thing in AppleScript?

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 ,
Sep 21, 2010 Sep 21, 2010

Here's an AppleScript which will do the same thing. Cut everything between the dashes can paste into a new window in the AppleScript editor. Compile it and then Save it with a name like SaveAsAI9.scpt. Put it in the folder Adobe Illustrator CSX>Presets>Scripts and restart Illustrator. Now you can run the script on a folder of files and select a new folder to save them and will have AI9 files.


-- BEGIN CODE

set fileTypes to {"EPSF", "PDF ", "ART5", "TEXT"} -- file types available to resave as Illustrator

-- get a sourceFolder that holds the files to resave as AI
set sourceFolder to (choose folder with prompt "Choose a folder with files to resave as Illustrator:") as text

-- get a list of files of the defined type in the sourceFolder
tell application "Finder" to set workingFiles to (every file of folder sourceFolder whose file type is in fileTypes) as alias list
-- now you have your fileList argument

-- get a destinationFolder to hold the PDFs
set destinationFolder to choose folder with prompt "Choose a folder to hold the Illustrator files:"

SaveFilesAsIllustrator9(workingFiles, destinationFolder)

on SaveFilesAsIllustrator9(fileList, destinationFolder)
    set destinationPath to destinationFolder as string
    repeat with aFile in fileList
        tell application "Finder"
           
            set fileName to displayed name of aFile -- get displayed name
            set AppleScript's text item delimiters to "."
            set newFileName to text item 1 of fileName
            set newFilePath to destinationPath & newFileName & ".ai"
           
        end tell
        tell application "Adobe Illustrator"
            open aFile forcing CMYK with options {update legacy text:true}
            save current document in file newFilePath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 9, embed linked files:true, font subset threshold:0.0}
            close current document saving no
        end tell
    end repeat
end SaveFilesAsIllustrator9


-- END CODE

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
Explorer ,
May 29, 2011 May 29, 2011
LATEST

I found the Applescript from Larry G. Schneider to be a great solution . . . ALMOST.  Seems like Adobe has abandoned the info Finder uses, the "file type." So I added another few lines that ALSO recognize files whose "kind" is "Adobe Illustrator Document."

Here's the code. (NOTE: This version is suited to my prefs, which is to resave as CS4. For your purposes, you would simple edit the script, changing "compatibility:Illustrator 14" to "compatibility:Illustrator 9" .)

-- BEGIN CODE:

set fileTypes to {"EPSF", "PDF ", "ART5", "TEXT"} -- file types available to resave as Illustrator

-- get a sourceFolder that holds the files to resave as AI

set sourceFolder to (choose folder with prompt "Choose a folder with files to resave as Illustrator CS4:") as text

-- get a list of files of the defined type in the sourceFolder

tell application "Finder" to set workingFiles to (every file of folder sourceFolder whose file type is in fileTypes) as alias list

-- now you have your fileList argument

-- look again, getting AI docs whose "file type" is missing (due, presumably, to CS file format changes):

tell application "Finder" to set moreFiles to (every file of folder sourceFolder whose kind is "Adobe Illustrator Document") as alias list

set workingFiles to workingFiles & moreFiles

-- get a destinationFolder to hold the new files

set destinationFolder to choose folder with prompt "Choose a folder to hold the Illustrator files:"

SaveFilesAsIllustrator14(workingFiles, destinationFolder)

on SaveFilesAsIllustrator14(fileList, destinationFolder)

set destinationPath to destinationFolder as string

repeat with aFile in fileList

tell application "Finder"

set fileName to displayed name of aFile -- get displayed name

set AppleScript's text item delimiters to "."

set newFileName to text item 1 of fileName

set newFilePath to destinationPath & newFileName & ".ai"

end tell

tell application "Adobe Illustrator"

open aFile forcing CMYK with options {update legacy text:true}

-- amend the "compatibility:" value to your preference (which might be followed up by amending some of the above lines, esp. the prompt in line 4):

(*

compatibility (Illustrator 10/Illustrator 11/Illustrator 12/Illustrator 13/Illustrator 14/Illustrator 3/Illustrator 8/Illustrator 9/Japanese 3) : what Illustrator file format version to create ( default: Illustrator 14 )

*)

save current document in file newFilePath as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 14, embed linked files:true, font subset threshold:0.0}

close current document saving no

end tell

end repeat

end SaveFilesAsIllustrator14

-- END CODE

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