In CS3 & 4 I can do it through menu actions (not supported in CS & CS2
Well ... as you said ... not in those older versions. Why not make up a name on the spot? It doesn't matter for its 'unused' status.
The unused swatches can be found as a document property "unusedSwatches":
Array of Swatch readonly The swatches that are not being used.
(you gotta love those helpful descriptions).
Search the forum, I might of made someone else a working 'delete unused' script.
[Edit] Got it; it's part of the script here: http://forums.adobe.com/thread/491014?tstart=1
Not sure what part to use...clarify?
Ah -- I see I used it the other way around (generating a list of used colors from the entire document swatch list -- and I was pretty content with this!).
Off top of head, you might aim at sth like:
while (app.activeDocument.unusedSwatches.length > 0) app.activeDocument.unusedSwatches.remove();
As you keep on removing item #0 (the first), the unusedSwatches array should decrease in length until it disappears into the tiny black hole inside your computer (leaving just its name and a zero length array as a lingering singularity).
Untested, so it might object against stuff like mixed inks. Pretty sure it would work with fairly regular color swatches, tho'.
Hi Seth / Jongware,
I think this method will only work for normal swatches.
In case of Gradiant swatches [manualy CMYK color applied] it wouldn't work, because of unnamed colors.
So before deleting the swatch check its name not as empty.
var myDocument = app.activeDocument;