Indesign - merge duplicate swatches

Is there a way to find and merge duplicate swatches in Indesign?

That’s precisely what the merge command does.

So if I have a document with the swatch “D4” and there are duplicate versions of it (say “D4 2”, D4 3", “D4 7”), to merge those duplicates so that only D4 appears I would use say:


tell application "Adobe InDesign CS6"
	activate
	tell front document
try
merge "D4" with {"D4 1", "D4 2", "D4 3", "D4 4", "D4 5", "D4 6", "D4 7", "D4 8", "D4 9", "D4 10"}
end try
end tell

Did you try it?

Yeah, doesn’t work.
Am I going in the right direction?

You cannot use the merge command with just a literal string.
Normally these commands need object parameter

From the Indesign (CS3) dictionary:

direct parameter required reference Supported by the following objects: mixed ink, mixed ink group, gradient, swatch, color, tint.
with required anything The swatches to merge. Can accept: list of swatches, swatch or string.

PS: While searching for the right syntax, comment out any try block to get at least a significant error message

thanks guys.
I’m a little confused but I guess you’re saying the code needs to read:
merge color with value {80, 0, 0, 0} with “D4”

Obviously not the right scripting code, but will that format work?

No – something like:

merge color "D4" of document 1 with {color "D4 1" of document 1, ...}

Use colour/swatch/etc as appropriate.

Hi. What Stefan pointed out was just that the list items need to refer to something, such as a swatch, otherwise, InDesign has no idea of what “D4 1” et al. might consist. I prefer this form to Shane’s, as you don’t have to keep retyping the object class and document reference for every swatch.

tell application "Adobe InDesign CS6"'s document 1 to merge swatch "D4" with (swatches whose name is in {"D4 1", "D4 2", "D4 3", "D4 4", "D4 5", "D4 6", "D4 7", "D4 8", "D4 9", "D4 10"})

Yes, that’s much simpler. I haven’t tried it, but the dictionary implies using just strings will also work for the with parameter.

Oh ok, got you.
Thank you very much guys. As you can tell I’m learning a lot as I go.
Appreciate the help