Search code examples
javascriptadobe-illustrator

Script for Illustrator to adjust global color accross multiple documents


Is there a way to change the color values of a global color in Illustrator with e.g. an javasript script in multiple documents? Let's say I have 100 documents which use all the same named global color and I want to adjust this one in all documents at the same time without having to open all documents manually. I did not find a solution, yet, but maybe someone has an idea, how this could work?

Best, Hirschferkel


Solution

  • For a simplest case you can use this:

    var folder = Folder("d:/_");
    var files = folder.getFiles("*.ai");
    
    for (var i=0; i<files.length; i++) {
    
        var doc = app.open(files[i]);
        var my_color = doc.swatches.getByName("color");
    
        my_color.color.spot.color.cyan    = 100;
        my_color.color.spot.color.magenta = 0;
        my_color.color.spot.color.yellow  = 100;
        my_color.color.spot.color.black   = 0;
    
        doc.save();
        doc.close();
    }
    

    It gets all ai files from folder d:\_. Changes the color with name color into the CMYK green (100,0,100,0). And saves all the files.