Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to add a layer for each color fill code

Explorer ,
Sep 06, 2025 Sep 06, 2025

i have designs with around 30 colours, with codes like these.  #009245 and #ec3744. The colours i use change a lot so i have to individually select all and group each color.

 

I would like to know if there is already a script for grouping each color fill or adding each color fill to a different layer.

 

I tried Meta to make one but it did not work :

var doc = app.activeDocument;
var items = doc.pageItems;
var colors = {};

for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.fillColor) {
var color = item.fillColor.toString();
var hexMatch = color.match(/(\w{6})/g);
if (hexMatch) {
var hexCode = hexMatch[0].toLowerCase();
if (!colors[hexCode]) {
colors[hexCode] = [];
}
colors[hexCode].push(item);
}
}
}

for (var hexCode in colors) {
var layer = doc.layers.add();
layer.name = hexCode;
for (var j = 0; j < colors[hexCode].length; j++) {
colors[hexCode][j].moveToBeginning(layer);
}
}

 

Is there anything that is already made? I've searched but cant find anything that puts each color fill (in a closed shape or path) into a group or layer

TOPICS
How-to , Scripting
120
Translate
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

Explorer , Sep 06, 2025 Sep 06, 2025
Adobe
Explorer ,
Sep 06, 2025 Sep 06, 2025
Translate
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
Community Expert ,
Sep 06, 2025 Sep 06, 2025

can you elaborate? can you show before and after screenshots or share sample files?

 

ok, I see you found your answer

Translate
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 ,
Sep 07, 2025 Sep 07, 2025
LATEST

thanks , yes 🙂  thanks for checking .. People like you that help others are gentlemen to the extreme. (and gentlewoman) . Thanks

Translate
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