Convert CMYK process to RGB spot
I'm a relative novice when it comes to scripting, so I've been trying to scrape together the code I need from here and other sources but it isn't quite doing what I want it to do.
I have CMYK icon files that contain 2 global swatches I need to convert to RGB and change the colour values, whilst also converting to spot colours from process. Lastly, I need to rename the 2 swatches. One script I have started is;
var docRef = activeDocument;
app.executeMenuCommand('doc-color-rgb');
var currentSwatchColor = docRef.swatches['CMYK Colour One'].color.spot.color;
currentSwatchColor.red = parseInt(20);
currentSwatchColor.green = parseInt(20);
currentSwatchColor.blue = parseInt(20);
currentSwatchColor.colorType = ColorModel.SPOT;
currentSwatchColor.spotKind = SpotColorKind.SPOTRGB;
This changes the CMYK colour swatch to the specific RGB I need but doesn't make it a spot.
To rename the swatches I have;
for (var i = 0; i < documents.length; i++) {
for (var myCounter = 0; myCounter < docRef.spots.length; myCounter++) {
docRef.spots[myCounter].locked = false;
docRef.spots[myCounter].name = docRef.spots[myCounter].name.split('CMYK Colour One').join('RGB Colour One');
}
}
The above works to rename the swatch but I'm guessing it's not the most simple or elegant way to do it - I found it elsewhere and it works.
One thing I haven't been able to find a solution to is renaming the existing filename, going from "CMYK XXX" to "RGB XXX" in the same file location.
Any help would be much appreciated!