Is there a way to save the current document to a different file-type with a different name like you would when going through the “Save a Copy…” menu in Illustrator CS3?
Hi
There doesn’t seem to be an easy way to do this in illustrator via a standard save command in the dictionary.
try this:
ell application "Adobe Illustrator"
set mypath to file path of document 1
set docName to name of document 1
set thetarget to (mypath & space & "copy.ai" as string)
save document 1 in thetarget as Illustrator
close document 1
end tell
tell application "Finder"
set t to name of file thetarget
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ".ai "
set newText to text items of t
set AppleScript's text item delimiters to " "
set newText to newText as text
set AppleScript's text item delimiters to OldDelims
set name of file t to newText
end tell
Let me know how you get on with this!
you would have to change a few things for different file types this just assumes its a standard illustrator doc.
Subscription didn’t seem to work, so my apologies if I’m responding late.
What I was trying to do is saving an .ai file as a .svg file without changing the name or file type of the currently open file. When exporting from illustrator as a different file format with a different name, the open file will change to the new name and format. I know it can be done with applescript in Photoshop by writing something like “with copying” at the end of the line of code.
Hi
yep i see the property for it in Photoshop but can’t find anything in illustrator
so i’m not sure if it can be done!
it seems unlikely!
SVG is an export option not a save option. see export class for the details.
export Doc_Ref to New_File as SVG with options ¬
{class:SVG export options,}
Include the properties you require in the list.
The only way around it I could think of is making a copy of the currently open document, renaming and exporting that copy as an .svg and then close it. But I can’t figure out how to make a copy of the current document. The documentation seems to suggest it can be done, but I keep getting an error message: “clone not allowed”.
Yes, I got a bit confused between Save and Export when writing my post. Either way, Export doesn’t seem to give any ways to save as a copy.
The variable New_File that you are exporting your open document into will be creating your copy. When ever you save a document to a new location you get a duplicate of it at the point of saving/exporting. The coping that you get in Photoshop allows you to make multiple saves whilst keeping the original document open.
Maybe in Photoshop, but this is Illustrator we’re talking about. No matter what I try, it keeps changing the name and type of the current document when exporting.
There is no direct way to do this that I can see in illustrator (at least with CS2). You would need to open original file, export in to new file, close new file, reopen original file, do what ever else you need to do with this. To my knowledge the with copying is a Photoshop option only, I’ve never used the save as SVG before but now see why you would prefer the with copying parameter. SVG behaves differently to the other exports in both scripting and the GUI. This is what I tested with:
set New_Location to (path to desktop as Unicode text)
set Original_File to choose file with prompt "Please locate an Adobe Illustrator file" without invisibles
--
tell application "Adobe Illustrator"
activate
open Original_File with options {update legacy text:true} without dialogs
set Doc_Ref to the current document
set New_Name to "Test_File"
set New_File to New_Location & New_Name & ".psd"
export Doc_Ref to New_File as Photoshop with options ¬
{class:Photoshop export options, antialiasing:true, color space:CMYK, compatibility:Photoshop 8, editable text:true, maximum editability:true, write layers:true, resolution:300, warnings:false}
delay 6
-- do your other stuff here the original file is still open
close Doc_Ref with saving
end tell
set New_Location to (path to desktop as Unicode text)
set Original_File to choose file with prompt "Please locate an Adobe Illustrator file" without invisibles
--
tell application "Adobe Illustrator"
activate
open Original_File with options {update legacy text:true} without dialogs
set Doc_Ref to the current document
set New_Name to "Test_File"
set New_File to New_Location & New_Name & ".svgz"
export Doc_Ref to New_File as SVG with options ¬
{class:SVG export options, compressed:true, coordinate precision:3, CSS properties:style attributes, document encoding:ASCII, DTD:SVG 1.1, embed raster images:false, enable auto kerning:false, enable text on path:false, font subsetting:all glyphs, font type:CEF font, include file info:false, include variables and datasets:false, optimize for SVG Viewer:false, preserve editability:false, slices:false}
delay 6
-- Same as using "save as" in the GUI Illustrator thinks the SVG is open!
close Doc_Ref without saving
open Original_File with options {update legacy text:true} without dialogs
-- do your other stuff here
end tell
Well, as I said earlier, the other solution would be to duplicate the currently open document in Illustrator. According to the Illustrator applescript reference, the duplicate command should apply to documents, but I can’t seem to get it to work. Could it be that there was the intention of adding the duplicate command for currently open documents but that it never got implemented?