Skip to main content
Participant
December 13, 2017
Answered

Merging an Adjustment layer to many layers.

  • December 13, 2017
  • 5 replies
  • 9086 views

Hello, I believe after 20 years of photoshop, someone must have implemented this feature since it is very frustrating working without it.

I have an Adjustment Layer.
Below it, I have 50 Layers.
I WANT SPECIFICALLY  MERGE the adjustment layer to  EACH OF all the below 50 layers.
I DON'T want merge all the layers.
I DON'T WANT to group the layers and have the adjustment layer there.

What I would do now is to duplicate the Adjustment layers 50 times and click for each couple (Adjustment layer-Picture Layer), Merge Layers.

This is unfeasible and very frustrating.
I have heard about strange things with smart objects or batch, ALL INCOMPLETE solutions. THIS is a DAILY PROBLEM of millions artists.
PLEASE provide STEP BY STEP solutions!!
Thank you very much!!

This topic has been closed for replies.
Correct answer Chuck Uebele

Try this script. You have to have the adjustment layer selected when you run the script! It will not merge with a smart object nor a group (layer set). It will only merge with layers that are below it, and that are in the same "group" such as the top level of the file, or in a layer set.

#target photoshop

var doc = activeDocument;

var adjL = doc.activeLayer

for(var i = adjL.parent.layers.length-1;i>0;i--){

    doc.activeLayer = adjL.parent.layers;

    var nextL = doc.activeLayer

    if(nextL.name == adjL.name){break;}

    if(nextL.typename !='LayerSet'){

        try{

            doc.activeLayer = adjL

            dupeL ();

            var tempL = doc.activeLayer

            tempL.move(nextL,ElementPlacement.PLACEBEFORE);

            mergeL ();

            }

        catch(e){

            tempL.remove()

            }

        }

   

    }

function mergeL(){

     var idMrgtwo = charIDToTypeID( "Mrg2" );

        var desc5 = new ActionDescriptor();

    executeAction( idMrgtwo, desc5, DialogModes.NO );  

    }

function dupeL(){

    var idCpTL = charIDToTypeID( "CpTL" );

        executeAction( idCpTL, undefined, DialogModes.NO );

    }

5 replies

Earth Oliver
Legend
July 1, 2022

For anyone who needs this workflow, there's a free tool called Layers to Files (Fast) that can automate this and a few other essential workflows. Just add your adj layer on top, then choose Top Layer as Foreground.
https://github.com/antipalindrome/Photoshop-Export-Layers-to-Files-Fast
https://github.com/antipalindrome/Photoshop-Export-Layers-to-Files-Fast/releases/tag/v2.6.0

Participant
February 27, 2024

Thank You!

I know little to nothing about scripts, but this worked prferctly for me.

Participant
July 1, 2022

HOW DO I CREATE A SCRIPT FILE FOR THIS CODE ? I AM GETTIN

 

Error 1200 IN THIS LINE doc.activeLayer = adjL.parent.layers;

Tom Winkelmann
Inspiring
July 1, 2022

Replace...

    doc.activeLayer = adjL.parent.layers;

...with...

    doc.activeLayer = adjL.parent.layers[i];

 

Be sure you have selected the adjustment layer when running the script

Participant
July 1, 2022

Thanks!!!!!!

Chuck Uebele
Community Expert
Community Expert
December 14, 2017

If you still want to do it manually, you can copy the adjustment layer, then use alt/opt-[ to go down to the next layer, ctrl/cmd-V to paste the adjustment layer, then ctrl/cmd-E to merge it down. It saves the step of duplicating the adjustment layer and moving it.

Mohit Goyal
Community Manager
Community Manager
February 16, 2018

Moved to Photoshop Scripting

Thanks,

Mohit

chanaart
Community Expert
Community Expert
December 14, 2017

Can you send the demo file and explain so I can re do it and see how to make it happen?

chana

Chuck Uebele
Community Expert
Chuck UebeleCommunity ExpertCorrect answer
Community Expert
December 14, 2017

Try this script. You have to have the adjustment layer selected when you run the script! It will not merge with a smart object nor a group (layer set). It will only merge with layers that are below it, and that are in the same "group" such as the top level of the file, or in a layer set.

#target photoshop

var doc = activeDocument;

var adjL = doc.activeLayer

for(var i = adjL.parent.layers.length-1;i>0;i--){

    doc.activeLayer = adjL.parent.layers;

    var nextL = doc.activeLayer

    if(nextL.name == adjL.name){break;}

    if(nextL.typename !='LayerSet'){

        try{

            doc.activeLayer = adjL

            dupeL ();

            var tempL = doc.activeLayer

            tempL.move(nextL,ElementPlacement.PLACEBEFORE);

            mergeL ();

            }

        catch(e){

            tempL.remove()

            }

        }

   

    }

function mergeL(){

     var idMrgtwo = charIDToTypeID( "Mrg2" );

        var desc5 = new ActionDescriptor();

    executeAction( idMrgtwo, desc5, DialogModes.NO );  

    }

function dupeL(){

    var idCpTL = charIDToTypeID( "CpTL" );

        executeAction( idCpTL, undefined, DialogModes.NO );

    }

renatot34194169
Participant
May 11, 2023

This is grate!

We noticed a little correction needed at line 5.
doc.activeLayer = adjL.parent.layers[i];

Thanks again for the solution!