Hi all,
I’ve been searching on this site and elsewhere for awhile now, but I can’t quite get my script working.
What I’m trying to do is have Illustrator save out the respective layers that have my cutting path and registration marks to a new file with “-CUT” appended to it to the same directory as the open file. To do this it should:
• delete every layer except my cut and regmarks layers - this part works.
• delete all artboards except the first one - this does NOT work. It seems the last artboard is saved, not the first one.
• append “-CUT.” (I have to add that dot in there or it just saves over the original file) to the file name - this does NOT work correctly.
For some reason Illustrator always adds another file extension like so:
Original file - myfilename.eps
New file from script - myfilename.eps-CUT.eps
Here is the script I have so far:
tell application "Adobe Illustrator"
set locked of every layer of the current document to false
set visible of every layer of the current document to true
set countArtboards to count artboards in document 1
if countArtboards > 1 then
delete artboard countArtboards of document 1
else
display alert "Cannot remove the only artboard in the document"
end if
delete (every layer of document 1 whose name does not start with "Cut" and name does not contain "regmark")
set filepath to (file path of current document) as text
set fileName to name of current document as text
set fullPath to filepath & fileName
set newFilePath to filepath & "-CUT."
save current document in file newFilePath as eps with options {class:EPS save options, compatibility:Illustrator 13, preview:color TIFF, include document thumbnails:true, embed all fonts:true, CMYK PostScript:true, PostScript:level 2}
close current document
end tell
So to sum up:
The script works, but it:
• saves the wrong artboard. I want it to only save the first artboard (maybe that if/then/else statement is not needed?)
• adds extra ‘.eps’ to the filename
I’d like to fix all this if possible. Thanks much for any help.