Skip to main content
mo54891077
Participant
March 14, 2019
Answered

Script to Merge each main group (not subgroup) in to a layer

  • March 14, 2019
  • 1 reply
  • 4212 views

Hi

I have a client who wants to receive his image in the following format

one layer for the background

another layer for the shaddow

another layer for the object

I am doing many images so i am looking a way to Script to Merge each main group (not subgroup) in to a layer

then while i work i can make sure to work in these groups

is there a way to do it?

Thank you in advance

This topic has been closed for replies.
Correct answer SuperMerlin

Something like this?

#target photoshop;

while(app.activeDocument.layerSets.length){

activeDocument.activeLayer = app.activeDocument.layerSets[0];

executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);

activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);

}

1 reply

SuperMerlin
SuperMerlinCorrect answer
Inspiring
March 14, 2019

Something like this?

#target photoshop;

while(app.activeDocument.layerSets.length){

activeDocument.activeLayer = app.activeDocument.layerSets[0];

executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);

activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);

}

Participating Frequently
November 28, 2023

Hi SuperMerlin

Thank you for the script.
I ALMOST works in my case. 

Is it possible to rewrite the script, so that photoshop selects the top layer (In my case a Artboard group) ?
When using "select --> All layers" i get a error (See attached) But if i manually select the top artboard, the scripts runs perfect!

 The script is for a save action, converting multiple (and different amount) of artboards to 16/bit, flattening and converting back to 8/bit. And then exporting every layer into seperate files.  

 

Thank you so much in advance. 🙂


c.pfaffenbichler
Community Expert
Community Expert
November 28, 2023

I don’t understand your scenario, could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible of the starting point and intended result?