Copy link to clipboard
Copied
We always use the same spot colour in all our documents but unfortunately its not always input the same way.
Is it possible to create a script to search for a name in the swatches panel and rename to keep it consistant.
Change 'Text Black' to 'Text black'.
I usually just change this manually but if i could add a script to my batch process scipts it would be great.
Thanks
Steph
Hi,
You can try following snippet to rename the swatch in single document,
var doc = app.activeDocument;
try {
var blackSwatch = doc.swatches.itemByName('Text Black');
} catch (e) {
}
if (blackSwatch.isValid) {
blackSwatch.name = 'Temp';
blackSwatch.name = 'Text black';
}
NOTE: When I try to give name direct "Text black" before giving name as "Temp", it does not update. I am not sure about the reason, but I am also looking for a reason behind it. Is it because of case insensiti
...Copy link to clipboard
Copied
Hi,
You can try following snippet to rename the swatch in single document,
var doc = app.activeDocument;
try {
var blackSwatch = doc.swatches.itemByName('Text Black');
} catch (e) {
}
if (blackSwatch.isValid) {
blackSwatch.name = 'Temp';
blackSwatch.name = 'Text black';
}
NOTE: When I try to give name direct "Text black" before giving name as "Temp", it does not update. I am not sure about the reason, but I am also looking for a reason behind it. Is it because of case insensitive? If anyone knows please let me know.
Copy link to clipboard
Copied
THANK YOU!
Copy link to clipboard
Copied
You are welcome.
Copy link to clipboard
Copied
Hi,
Just to add another solution in case someone is looking for something similar in the future.
var mySwatches = app.activeDocument.swatches;
// start at 4, because there are a number of swtches we cannot change.
for ( var i = 4; i < mySwatches.length; i++){
var mySwatch = mySwatches[i];
mySwatch.name = standardisename ( mySwatch.name);
}
function standardisename ( name){
// your code here to change the name as you want
return name
}
This way you could apply style guides to the naming of swatches and have them enforced by a script.
Malcolm
Copy link to clipboard
Copied
Hi Malcolm,
your script could fail because one can move around all swatches with names in brackets as well.
Obviously you assume that the swatches indexed 0,1,2,3 should never be touched.
Sample with my German InDesign where the swatches with index 0,1,2,3 are not the ones you'd expect:
Regards,
Uwe Laubender
( ACP )