This script will convert any spot colors to process color, and any other color to a global color. It was pieced together and modified from 2 other scripts I found here while searching. Tested and working in Illustrator CS2. I don’t know about other versions. The “on convertSpotSwatchesToProcess” part goes through and replaces existing swatches with new ones of the same name and color info. I tried many many things to get it to convert the existing swatches to global swatches to no avail. This was the fall back option.
tell application "Adobe Illustrator"
try
set color type of (spots of current document whose name is not "[Registration]" and its color type is spot color) to process color
end try
tell current document
if exists (swatches whose class of color of it is CMYK color info) then
set t to name of every swatch whose class of color of it is CMYK color info
my convertSpotSwatchesToProcess(t)
end if
end tell
end tell
on convertSpotSwatchesToProcess(list_of_swatches)
tell application "Adobe Illustrator"
tell current document
set replacementSwatches to {}
set deleteSwatches to {}
set cmykSwatches to every swatch whose class of color of it is CMYK color info and name is in list_of_swatches
repeat with thisSwatch in cmykSwatches
set swatchName to name of thisSwatch
set swatchColor to color of thisSwatch
copy {name:swatchName, color:swatchColor} to end of replacementSwatches
set end of deleteSwatches to thisSwatch
end repeat
delete deleteSwatches
repeat with thisReplacement in replacementSwatches
make new spot at end with properties thisReplacement
end repeat
end tell
end tell
end convertSpotSwatchesToProcess
Hi relishgargler
I used this script and found it very useful. However, on closer inspection, the first part:
try
set color type of (spots of current document whose name is not "[Registration]" and its color type is spot color) to process color
end try
seems to do the trick on it’s own in CS5.1
It won’t work on spot colours that are defined as Lab, but will work with spots defined as RGB.
Anyway, for my purposes it works fine with just that first bit. Thanks!
Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)
Like I said, I don’t have any other versions to test on. The first part should convert all your spot colors to process, but won’t convert any other colors to global colors, which was actually a very important part of what I needed it to do. You’re right though, if all you need is to get rid of spot colors, the first part should do just fine.
Fabulous script but would like to convert it into application so you batch the chosen docs. I’m getting an error:
Can’t make data into expected type
This is what I have so far can someone advise me?
set source_folder to choose file with prompt "Select folder containing Illustrator docs to change spot to process colors" with multiple selections allowed without invisibles
tell application "Finder" to set item_list to every item of source_folder as alias list
tell application "Adobe Illustrator"
activate
repeat with DocAlias in item_list --(loops thru docs)
set doc to open DocAlias
tell document 1
try
set color type of (spots of current document whose name is not "[Registration]" and its color type is spot color) to process color
end try
if exists (swatches whose class of color of it is CMYK color info) then
set t to (name of every swatch whose class of color of it is CMYK color info)
my convertSpotSwatchesToProcess(t)
end if
end tell
save doc
delay 3
close doc
end repeat
end tell
on convertSpotSwatchesToProcess(list_of_swatches)
tell application "Adobe Illustrator"
tell current document
set replacementSwatches to {}
set deleteSwatches to {}
set cmykSwatches to every swatch whose class of color of it is CMYK color info and name is in list_of_swatches
repeat with thisSwatch in cmykSwatches
set swatchName to name of thisSwatch
set swatchColor to color of thisSwatch
copy {name:swatchName, color:swatchColor} to end of replacementSwatches
set end of deleteSwatches to thisSwatch
end repeat
delete deleteSwatches
repeat with thisReplacement in replacementSwatches
make new spot at end with properties thisReplacement
end repeat
end tell
end tell
end convertSpotSwatchesToProcess
I have been working on this for almost a year & still I can’t get it to work. This is a different approach. When you run it it changes the colors to cmyk but I’m not successful making it to save & close the illustrators docs. It is ignoring completely the save & close handler on doExport(myExportFile). If I don’t ask how am I supposed to learn from the experts
Illustrator Cs4
--Convert Spot Colors. This seems to work ok; test it out.
set folderSelected to (choose folder with prompt "Select folder of files to process" without multiple selections allowed)
set filesProcessed to processFiles(folderSelected)
filesProcessed
--=============
--HANDLERS
--=============
(*Converts spot colors to process colors*)
on processFiles(folderToProcess)
set filesProcessed to 0 --initialize counter
set documentList to getAliasList(folderToProcess) --get alias list of files in folder
set documentCount to length of documentList
tell application "Adobe Illustrator"
--set user interaction level
set origLevel to user interaction level
set user interaction level to never interact
--parse through list and convert spot colors
repeat with i from 1 to documentCount
set documentFile to item i of documentList
open documentFile
set docRef to document 1
try
set spotColorList to (every spot of docRef whose name does not start with "[Registration]")
if length of spotColorList > 0 then
repeat with j from 1 to length of spotColorList
set color type of item j of spotColorList to process color
end repeat
end if
set filesProcessed to filesProcessed + 1
end try
end repeat
set user interaction level to origLevel
end tell
return filesProcessed
end processFiles
on doExport(myExportFile)
--=================
--myfilename to name of (info for myexportfile)
--You use the info for command from the Scripting Addition to get the name of the file passed to your handler.
set myFileName to name of (info for myExportFile)
--=================
--set mynewfile to (folderSelected as string) & myfilename & mysuffix as string
--You construct a new name for your export file. including the output-folder path, original name, and new file extension.
set myNewFile to (folderSelected as string)
--=================
--tell app "Illustrator" You start talking to Illustrator
tell application "Adobe Illustrator"
--=================
-- open myexportfile You must have Illustrator open the file to export.
open myExportFile
--=================
--document 1 in file mynewfile as eps with options {compatibility: ...}
--Next, in one line you export the file as an EPS with several optional settings.
save document 1 in file myNewFile as eps with options {class:EPS save options, preview:color TIFF, overprint:preserve, embed all fonts:true, embed linked files:false, include document thumbnails:true, compatible gradient printing:false, CMYK PostScript:true, PostScript:level 3}
--=================
-- close document 1 saving no end tell end doExport
--You close the document without saving it before ending your conversation with Illustrator and your doExport handler
close document 1 saving no
end tell
end doExport
(*Returns list of file aliases from the Finder *)
on getAliasList(folderToProcess)
try
tell application "Finder"
set aliasList to (every file of folder folderToProcess as alias) as list
end tell
on error from fromItem
set aliasList to fromItem as list
end try
return aliasList
end getAliasList
Model: iMac intel 10.6.8
AppleScript: 2.1.2
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)
Sorry, I can’t help you any farther than the original script. I quit that job about a year and a half ago and no longer have access to the machines or programs I was working on. I do seem to reall they changed some of the AppleScript commands in CS3 or CS4, breaking this script. I think it was actually easier than what I wrote to perform the same task in newer versions. I seem to recall you could just convert the colors directly instead of the runaround with the intermediary color profile.
Hi Nellburn
With the script you posted, the handler was not being run at all. Regardless of its content nothing would happen. The first thing to do is to call the doExport handler, so I inserted that just before the end of your repeat. Next thing is to make that handler work. Your handler was going to try to open documents again, but you already had done that with the first handler. I chopped all that out and just added a line which retrieved the file path. By saving as eps, Illustrator automatically changes the file extension.
This works on CS5. Dunno about CS4
--Convert Spot Colors. This seems to work ok; test it out.
set folderSelected to (choose folder with prompt "Select folder of files to process" without multiple selections allowed)
set filesProcessed to processFiles(folderSelected)
filesProcessed
--=============
--HANDLERS
--=============
(*Converts spot colors to process colors*)
on processFiles(folderToProcess)
set filesProcessed to 0 --initialize counter
set documentList to getAliasList(folderToProcess) --get alias list of files in folder
set documentCount to length of documentList
tell application "Adobe Illustrator"
--set user interaction level
set origLevel to user interaction level
set user interaction level to never interact
--parse through list and convert spot colors
repeat with i from 1 to documentCount
set documentFile to item i of documentList
open documentFile
set docRef to document 1
try
set spotColorList to (every spot of docRef whose name does not start with "[Registration]")
if length of spotColorList > 0 then
repeat with j from 1 to length of spotColorList
set color type of item j of spotColorList to process color
end repeat
end if
set filesProcessed to filesProcessed + 1
end try
-- run the handler to export and close
my doExport(documentFile)
end repeat
set user interaction level to origLevel
end tell
return filesProcessed
end processFiles
on doExport(myExportFile)
tell application "Adobe Illustrator"
set myNewFile to file path of document 1
save document 1 in myNewFile as eps with options {class:EPS save options, preview:color TIFF, overprint:preserve, embed all fonts:true, embed linked files:false, include document thumbnails:true, compatible gradient printing:false, CMYK PostScript:true, PostScript:level 3}
close document 1 saving no
end tell
end doExport
(*Returns list of file aliases from the Finder *)
on getAliasList(folderToProcess)
try
tell application "Finder"
set aliasList to (every file of folder folderToProcess as alias) as list
end tell
on error from fromItem
set aliasList to fromItem as list
end try
return aliasList
end getAliasList
Model: MacBook Pro 2.7 GHz Core i7 16GB RAM
Browser: Safari 537.31
Operating System: Mac OS X (10.8)