Javscript to delete the color swatches by name

Explorer ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

Hello Everyone,

 

I want to delete the color swatch namely "PANTONE Black C" in the active document if it available in the color swatches pallete using the Java Script.

 

Please guide me to figure out this.

TOPICS
Scripting

Views

57

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Feb 24, 2022 Feb 24, 2022
hey @Surya24  Try this ! var doc = app.activeDocument; for (i = 0; i < doc.swatches.length; i++) { var miColor = doc.swatches[i]; if (miColor.name== "PANTONE Black C") { miColor.remove(); } else{ continue; } }

Likes

Translate

Translate
Participant ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

hey @Surya24 

 

Try this !

 

var doc = app.activeDocument;
  
  for (i = 0; i < doc.swatches.length; i++) {
       var miColor = doc.swatches[i];
            if (miColor.name== "PANTONE Black C") {
     miColor.remove();
    } else{
continue;        
        }
  }

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

LATEST

Thank You so much

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines