Highlighted

Applying adjustment layer to multiple layers

New Here ,
Mar 12, 2019

Copy link to clipboard

Copied

Hi there,

I've read many posts with this same question and earlier in the year I found the perfect solution in a script. I have since updated Photoshop and the script disappeared. Now I can't find it again. What I need to do is apply the adjustment layer to all the layers in the group. I need to do this to every mouth layer of every character I have going into Character animator. There are several of these so the manual way of applying the adjustment is very tedious. Especially as Photoshop names the merged layer according the top layer so I have to go through and rename everything on top of all the manual layer merging management. The script was very neat, you would put the adjustment layer or layers inside a group with all the layers in need of adjusting then run the script and it would adjust all layers in the group. Massive time saver. Has anyone out there come across this script???? I love script writers, you are my heroes.

Screen Shot 2019-03-12 at 7.50.19 pm.png

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Try it. One of the adjustment layers located above the group should be active.

app.activeDocument.suspendHistory("Script", "f()");  

 

function f() 

    { 

    var doc = activeDocument; 

 

    var adj_layer = doc.activeLayer; 

    var parent = adj_layer.parent;

    for (var n = 0; n < parent.layers.length; n++) 

        {

        if (parent.layers == adj_layer)

            {

            for (++n; n < parent.layers.length; n++) 

                {

                if (parent.layers.typename == "LayerSet")

                    {

                    var set = parent.layers;

                    for (var i = set.artLayers.length-1; i >= 0; i--) 

                        {         

                        var layer = adj_layer.duplicate(set.artLayers, ElementPlacement.PLACEBEFORE) 

 

                        doc.activeLayer = layer;         

 

                        executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO); 

                        } 

                    adj_layer.remove(); 

                    return;

                    }

                }

            }

        }

    } 

Topics

Actions and scripting

Views

3.3K

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

Applying adjustment layer to multiple layers

New Here ,
Mar 12, 2019

Copy link to clipboard

Copied

Hi there,

I've read many posts with this same question and earlier in the year I found the perfect solution in a script. I have since updated Photoshop and the script disappeared. Now I can't find it again. What I need to do is apply the adjustment layer to all the layers in the group. I need to do this to every mouth layer of every character I have going into Character animator. There are several of these so the manual way of applying the adjustment is very tedious. Especially as Photoshop names the merged layer according the top layer so I have to go through and rename everything on top of all the manual layer merging management. The script was very neat, you would put the adjustment layer or layers inside a group with all the layers in need of adjusting then run the script and it would adjust all layers in the group. Massive time saver. Has anyone out there come across this script???? I love script writers, you are my heroes.

Screen Shot 2019-03-12 at 7.50.19 pm.png

Adobe Community Professional
Correct answer by r-bin | Adobe Community Professional

Try it. One of the adjustment layers located above the group should be active.

app.activeDocument.suspendHistory("Script", "f()");  

 

function f() 

    { 

    var doc = activeDocument; 

 

    var adj_layer = doc.activeLayer; 

    var parent = adj_layer.parent;

    for (var n = 0; n < parent.layers.length; n++) 

        {

        if (parent.layers == adj_layer)

            {

            for (++n; n < parent.layers.length; n++) 

                {

                if (parent.layers.typename == "LayerSet")

                    {

                    var set = parent.layers;

                    for (var i = set.artLayers.length-1; i >= 0; i--) 

                        {         

                        var layer = adj_layer.duplicate(set.artLayers, ElementPlacement.PLACEBEFORE) 

 

                        doc.activeLayer = layer;         

 

                        executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO); 

                        } 

                    adj_layer.remove(); 

                    return;

                    }

                }

            }

        }

    } 

Topics

Actions and scripting

Views

3.3K

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
Most Valuable Participant ,
Mar 12, 2019

Copy link to clipboard

Copied

If you install a new version of Photoshop did you copy the script into the new Photoshop version folder \Presets\scripts\ so it is installed into the new version pf Photoshop?

JJMack

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
Reply
Loading...
New Here ,
Mar 13, 2019

Copy link to clipboard

Copied

No I had forgotten about copying the scripts over when I updated. I will keep them somewhere separate in future like I do with all my other scripts so that if I forget again, I can retrieve them.

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
Reply
Loading...
Adobe Community Professional ,
Mar 12, 2019

Copy link to clipboard

Copied

Select adjustment layer.

Run the script.

app.activeDocument.suspendHistory("Script", "f()");

function f()

    {

    var doc = activeDocument;

    var adj_layer = doc.activeLayer;

    var set = doc.layerSets.getByName("Mouth");

    for (var i = set.artLayers.length-1; i >= 0; i--)

        {       

        var layer = adj_layer.duplicate(set.artLayers, ElementPlacement.PLACEBEFORE)

        doc.activeLayer = layer;       

        executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);

        }

    adj_layer.remove();

    }

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
Reply
Loading...
New Here ,
Mar 13, 2019

Copy link to clipboard

Copied

Thanks so much r-bin. I can't get it to work though. It says there's no such element as "Mouth". I tried it inside and outside of the group. Any suggestions?

Screen Shot 2019-03-13 at 6.59.43 pm.png

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
Reply
Loading...
Advocate ,
Mar 13, 2019

Copy link to clipboard

Copied

On my mac it works fine

try this way

you must rename the group in Mouth

then select the Adjustment level

and start the script

Monosnap-2019-03-13-12-27-00.png

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
Reply
Loading...
New Here ,
Mar 13, 2019

Copy link to clipboard

Copied

Thank you for helping but I can't understand why it doesn't work for me.

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
Reply
Loading...
New Here ,
Mar 13, 2019

Copy link to clipboard

Copied

Screen Shot 2019-03-14 at 1.08.43 pm.png

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
Reply
Loading...
Most Valuable Participant ,
Mar 13, 2019

Copy link to clipboard

Copied

Rename the Mouth group to X then rename Group X to Mouth make sure the group name is correct. That line should find Layer group Mouth. It does on my Windows 10 Photoshop CC 2019 system.  The order of the merge layer surprised me though. I expected the group would have the same number of laters not all layer merger in the group

Capture.jpg

JJMack

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
Reply
Loading...
Adobe Community Professional ,
Mar 14, 2019

Copy link to clipboard

Copied

Try it. One of the adjustment layers located above the group should be active.

app.activeDocument.suspendHistory("Script", "f()");  

 

function f() 

    { 

    var doc = activeDocument; 

 

    var adj_layer = doc.activeLayer; 

    var parent = adj_layer.parent;

    for (var n = 0; n < parent.layers.length; n++) 

        {

        if (parent.layers == adj_layer)

            {

            for (++n; n < parent.layers.length; n++) 

                {

                if (parent.layers.typename == "LayerSet")

                    {

                    var set = parent.layers;

                    for (var i = set.artLayers.length-1; i >= 0; i--) 

                        {         

                        var layer = adj_layer.duplicate(set.artLayers, ElementPlacement.PLACEBEFORE) 

 

                        doc.activeLayer = layer;         

 

                        executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO); 

                        } 

                    adj_layer.remove(); 

                    return;

                    }

                }

            }

        }

    } 

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
Reply
Loading...
New Here ,
Mar 14, 2019

Copy link to clipboard

Copied

Thank you r-bin, you're the BEST!!

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
Reply
Loading...
New Here ,
May 07, 2019

Copy link to clipboard

Copied

This works like a charm @r-bin ! Thanks alot

There is any way to tweak the code to make it work when you have layers using clipping mask like Layer 06 in the example?Untitled-1.jpg

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
Reply
Loading...
Adobe Community Professional ,
May 07, 2019

Copy link to clipboard

Copied

This is not a very beautiful script with great limitations. But still try.

Will not work on smart objects.

app.activeDocument.suspendHistory("Script", "f()");    

function f()   

    {   

    var doc = activeDocument;   

   

    var adj_layer = doc.activeLayer;   

 

    var parent = adj_layer.parent; 

 

    for (var n = 0; n < parent.layers.length; n++)   

        { 

        if (parent.layers == adj_layer) 

            { 

            for (++n; n < parent.layers.length; n++)   

                { 

                if (parent.layers.typename == "LayerSet") 

                    { 

                    var set = parent.layers

 

                    for (var i = 0; i < set.artLayers.length; i++)   

                        {           

                        var grouped = set.artLayers.grouped;

                        var layer = adj_layer.duplicate(set.artLayers, ElementPlacement.PLACEBEFORE)   

   

                        doc.activeLayer = layer;           

                        if (grouped && !layer.grouped) layer.grouped = grouped;

   

                        executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);   

                        }   

 

                    adj_layer.remove();   

                    return; 

                    } 

                } 

            } 

        } 

    }   

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
Reply
Loading...
New Here ,
May 07, 2019

Copy link to clipboard

Copied

Thank you so much for this code, you are a beautiful human being! That will save me so much time

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
Reply
Loading...
New Here ,
Nov 27, 2019

Copy link to clipboard

Copied

Hi!

Im trying this in PS 2020 but can´t get it to work so far. Just to be clear - I created a textfile pasted the code into it and saved it as script.jsx

Then I run the script in Photoshop but nothings happening.

Haven´t worked with scripts a lot so far so maybe I´m just missing something essential 🙂

 

Thanks for your help!

 

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
Reply
Loading...
New Here ,
Jul 09, 2020

Copy link to clipboard

Copied

HI there, Same issue in CC 2020, I tried renaming the group to Group 1, LayerSet, but nothing. How exactly does it need to be the layer structure for it to work. I have it like this
- Adjustment layer name

- Group 1

  --Layer 1

  --Layer 2

  --Layer...

 

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
Reply
Loading...
Community Beginner ,
Mar 13, 2019

Copy link to clipboard

Copied

Hi does this script work with layers such as multiply and color dodge?

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
Reply
Loading...
Adobe Community Professional ,
Mar 13, 2019

Copy link to clipboard

Copied

This will not work, just as it will not work if the layers intersect and translucent.

I think, that to replace the adjustment layer to the correction for the individual layer, in general case is impossible

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
Reply
Loading...
New Here ,
Mar 17, 2020

Copy link to clipboard

Copied

I am trying to do the same in Photoshop CC 2017. I have a file with many layers and one adjustment layer above many object layers. I want to apply that one adjustment layer to each individual object layer so I can save the layers as a mulitpage PDF. I am very comfortable with the things I genrerally do in Photoshop but do not use scripts regularily. I copy and paste the text above into ExtendScript Toolkit 2, save it as .jsx and try to implement it through Photoshop/Scripts/Browse. When I find the file and select it nothing happens. I have tryed editing the script and I do get errors in Photoshop so I know it is trying, but alas no reults. This is something that comes up now and again and I usually spend hours doing it by hand. It would be very helpful if this worked.

Thanks 

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
Reply
Loading...