7 Replies Latest reply on Sep 3, 2015 5:14 PM by Qwertyfly...

    Batch replace swatches

    katies92055710

      Does anyone have a trick to automate replacing spot color swatches over multiple illustrator files?

        • 1. Re: Batch replace swatches
          Qwertyfly... Level 4

          you need to provide more info.

          are you wanting to recolour your art?

          or just load a set of swatches to the swatch pallet?

          • 2. Re: Batch replace swatches
            katies92055710 Level 1

            Replace swatches in the art, specifically replacing 3 spot colors with different spot colors.

            • 3. Re: Batch replace swatches
              Qwertyfly... Level 4

              will this work?

               

              function swap_swatches(){
                  var doc = app.activeDocument;
                  var items = doc.pathItems;
                  for(var i = 0; i < items.length; i++){
                      if(items[i].fillColor.spot.name == "myRed"){
                          items[i].fillColor = doc.spots.getByName("myBrown").color;
                      }
                      if(items[i].fillColor.spot.name == "myYellow"){
                          items[i].fillColor = doc.spots.getByName("myGreen").color;
                      }
                      if(items[i].fillColor.spot.name == "myBlue"){
                          items[i].fillColor = doc.spots.getByName("myPurple").color;
                      }
                  }
              }
              swap_swatches();
              
              • 4. Re: Batch replace swatches
                Qwertyfly... Level 4

                or as a more flexible function...

                 

                function swap_swatches(OldColor,NewColor){
                    var doc = app.activeDocument;
                    var items = doc.pathItems;
                    for(var i = 0; i < items.length; i++){
                        if(items[i].fillColor.spot.name == OldColor){
                            items[i].fillColor = doc.spots.getByName(NewColor).color;
                        }
                    }
                }
                swap_swatches("myRed","myBrown");
                swap_swatches("myYellow","myGreen");
                swap_swatches("myBlue","myPurple");
                
                • 5. Re: Batch replace swatches
                  katies92055710 Level 1

                  Thanks, Is this Java Script? I have done a little bit with Apple Script, but I don't have too much experience with it. I'm going to try this and see if I can get it to work.

                  • 6. Re: Batch replace swatches
                    katies92055710 Level 1

                    I'm getting the following error when I try to run the script, then it is working on 2 of the swatches but not the final one. What's odd is I went back into my text document, and noticed an extra space in the swatch name for the one that wasn't working, so I fixed and ran it again. Then I still got the same message, and one of the other swatches stopped working.

                    Screen Shot 2015-09-03 at 10.03.49 AM.jpg

                    • 7. Re: Batch replace swatches
                      Qwertyfly... Level 4

                      this will be due to it not having a spot color.

                      this script only works for spot colors.

                       

                      also the spelling of the swatch names needs to be exact.