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

Hi

The intended result is to come from all these artboards, to flattenede seperate layers. (See attached)

The problem is, that the script comes with a error, when either "select all layers/groups" from the select tab, or when not selecting any layers. The only way it works, is by manually selecting the top layer (the one called Singlesalg_930x180) and i want the script to automaticly select the first group, not taking account for name etc. 


Is »Insert Photos« not good enough for you? 

 

Why don’t you include a simple line like 

activeDocument.activeLayer = activeDocument.layerSets[0];

at the start of the Script?