Hi @RoelofJanssen2 , here is a Javascript version of the script I posted above in 2018. I assign Command-V to the script—it converts the source color to the destination color when the names are the same:
var doc = app.documents.item(0);
//a list of document swatches
var cc = doc.swatches.everyItem().name
app.paste();
//a new list of document colors after the paste
var nc = doc.swatches.everyItem().name
//check the new list against the old list, if a color is not in the old list merge
for (var i = 0; i < nc.length; i++){
if (!checkItem(cc, nc[i])) {
var mergename = nc[i].substr(0, nc[i].length-2)
try {
doc.swatches.itemByName(mergename).merge(nc[i])
}catch(e) {}
}
};
/**
* Checks if an item is in an array
* @ param the array to check
* @ param the item to look for
* @ return true if the item is in the array
*
*/
function checkItem(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
... View more