Skip to main content
Participant
October 7, 2025
Answered

A batch action to edit one global color swatch across files

  • October 7, 2025
  • 1 reply
  • 175 views

I have 500+ files with the same swatches and I need to edit the values of one specific swatch across all of them. The swatch is saved as the values (C=40 M=65 Y=70 K=0), no name. These are basically all Save As, so settings and such across files are pretty much the same, FWIW.

I'm looking for a way to record an automation for this that I can then batch action across the whole folder.

I've tried a few variations of creating a new swatch an then alt+dragging but the automation doesn't overwrite the values on the old swatch, so maybe I end up with two swatches, but the image doesn't change.

Help!

Gearing up to change these files manually but yikes.

Correct answer RobOctopus

I think this will work for your needs. There is an early termination you can execute by holding the E key on your keyboard.

 

uploaded as a .txt file since it wont allow a jsx file. simply change the extension to be .jsx

code pasted below as well. you will need to edit the lines in the middle (39-42) for your desired updated swatch

 

#target illustrator
#targetengine session

var StartFolder = Folder.selectDialog("Pick the Folder containing the Files you want to ColorCorrect")
var FList = scanSubFolders(StartFolder);
var ContentLength = FList.length
var ProgressBarDialog = new Window("palette");
ProgressBarDialog.text = "Color Fixer Progress";
ProgressBarDialog.orientation = "column";
ProgressBarDialog.alignChildren = ["fill", "top"];
ProgressBarDialog.spacing = 10;
ProgressBarDialog.margins = 16;
var progressbar1 = ProgressBarDialog.add("progressbar", undefined, undefined, { name: "progressbar1" });
progressbar1.maxvalue = (ContentLength);
progressbar1.preferredSize.height = 15;
progressbar1.preferredSize.width = 500;
progressbar1.alignment = ["fill", "top"];
var progresstext = ProgressBarDialog.add("statictext", undefined, undefined, { name: "progresstext" });
progresstext.preferredSize.width = 500;
progresstext.alignment = ["fill", "fill"];
ProgressBarDialog.show();
progressbar1.value = 0;

ContentLoop: for (var f = 0; f < ContentLength; f++) {
    if (ScriptUI.environment.keyboardState.keyName == "E") {
        Canceled = true;
        break ContentLoop;
    }
    progressbar1.value = (f) + 1;
    progresstext.text = (f + 1) + "/" + (ContentLength) + " " + decodeURI(File(FList[f]).name) + ": Opening File...";
    ProgressBarDialog.update()
    /*OPEN THE DOC*/
    var ActDoc = app.open(FList[f])

    /* MAKE COLOR UPDATES HERE */
    var SwatchToUpdate = ActDoc.swatches.getByName('C=40 M=65 Y=70 K=0')
    /*uncomment which channels you want to alter. simply delete the 2 slashes preceeding the line
    and change the value to be the new intended value */
    //SwatchToUpdate.color.spot.color.cyan = 0
    //SwatchToUpdate.color.spot.color.magenta = 0
    //SwatchToUpdate.color.spot.color.yellow = 0
    //SwatchToUpdate.color.spot.color.black = 0

    /*SAVE DOC AND CLOSE */
    ActDoc.save()
    ActDoc.close()

    if (ScriptUI.environment.keyboardState.keyName == "E") {
        Canceled = true;
        break ContentLoop;
    }

}
ProgressBarDialog.close()
alert("Done!")

function scanSubFolders(tFolder) { // folder object
    var sFolders = new Array();
    var allFiles = new Array();
    sFolders.push(tFolder);
    for (var j = 0; j < sFolders.length; j++) { // loop through folders            
        var procFiles = sFolders[j].getFiles();
        for (var i = 0; i < procFiles.length; i++) { // loop through this folder contents
            if (procFiles[i] instanceof File) {
                if (procFiles[i].toString().search(/\.ai/i) > 0) {
                    allFiles.push(procFiles[i]);// if no search mask collect all files
                }
            } else if (procFiles[i] instanceof Folder) {
                sFolders.push(procFiles[i]);// store the subfolder
                scanSubFolders(procFiles[i]);// search the subfolder
            }
        }
    }
    return allFiles;
};

 

1 reply

RobOctopus
RobOctopusCorrect answer
Inspiring
October 7, 2025

I think this will work for your needs. There is an early termination you can execute by holding the E key on your keyboard.

 

uploaded as a .txt file since it wont allow a jsx file. simply change the extension to be .jsx

code pasted below as well. you will need to edit the lines in the middle (39-42) for your desired updated swatch

 

#target illustrator
#targetengine session

var StartFolder = Folder.selectDialog("Pick the Folder containing the Files you want to ColorCorrect")
var FList = scanSubFolders(StartFolder);
var ContentLength = FList.length
var ProgressBarDialog = new Window("palette");
ProgressBarDialog.text = "Color Fixer Progress";
ProgressBarDialog.orientation = "column";
ProgressBarDialog.alignChildren = ["fill", "top"];
ProgressBarDialog.spacing = 10;
ProgressBarDialog.margins = 16;
var progressbar1 = ProgressBarDialog.add("progressbar", undefined, undefined, { name: "progressbar1" });
progressbar1.maxvalue = (ContentLength);
progressbar1.preferredSize.height = 15;
progressbar1.preferredSize.width = 500;
progressbar1.alignment = ["fill", "top"];
var progresstext = ProgressBarDialog.add("statictext", undefined, undefined, { name: "progresstext" });
progresstext.preferredSize.width = 500;
progresstext.alignment = ["fill", "fill"];
ProgressBarDialog.show();
progressbar1.value = 0;

ContentLoop: for (var f = 0; f < ContentLength; f++) {
    if (ScriptUI.environment.keyboardState.keyName == "E") {
        Canceled = true;
        break ContentLoop;
    }
    progressbar1.value = (f) + 1;
    progresstext.text = (f + 1) + "/" + (ContentLength) + " " + decodeURI(File(FList[f]).name) + ": Opening File...";
    ProgressBarDialog.update()
    /*OPEN THE DOC*/
    var ActDoc = app.open(FList[f])

    /* MAKE COLOR UPDATES HERE */
    var SwatchToUpdate = ActDoc.swatches.getByName('C=40 M=65 Y=70 K=0')
    /*uncomment which channels you want to alter. simply delete the 2 slashes preceeding the line
    and change the value to be the new intended value */
    //SwatchToUpdate.color.spot.color.cyan = 0
    //SwatchToUpdate.color.spot.color.magenta = 0
    //SwatchToUpdate.color.spot.color.yellow = 0
    //SwatchToUpdate.color.spot.color.black = 0

    /*SAVE DOC AND CLOSE */
    ActDoc.save()
    ActDoc.close()

    if (ScriptUI.environment.keyboardState.keyName == "E") {
        Canceled = true;
        break ContentLoop;
    }

}
ProgressBarDialog.close()
alert("Done!")

function scanSubFolders(tFolder) { // folder object
    var sFolders = new Array();
    var allFiles = new Array();
    sFolders.push(tFolder);
    for (var j = 0; j < sFolders.length; j++) { // loop through folders            
        var procFiles = sFolders[j].getFiles();
        for (var i = 0; i < procFiles.length; i++) { // loop through this folder contents
            if (procFiles[i] instanceof File) {
                if (procFiles[i].toString().search(/\.ai/i) > 0) {
                    allFiles.push(procFiles[i]);// if no search mask collect all files
                }
            } else if (procFiles[i] instanceof Folder) {
                sFolders.push(procFiles[i]);// store the subfolder
                scanSubFolders(procFiles[i]);// search the subfolder
            }
        }
    }
    return allFiles;
};

 

Participant
October 24, 2025

This was perfect! Thank you so much!

I don't have much experience with scripts so it took a litlte figuring out (like had to change the file extension in the Info, not just on the file name) but then it's like magic.