Link in Zwischenablage kopieren
Kopiert
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.

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[n] == adj_layer)
{
for (++n; n < parent.layers.length; n++)
{
if (parent.layers[n].typename == "LayerSet")
{
var set = parent.layers[n];
for (var i = set.art...
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
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[i], ElementPlacement.PLACEBEFORE)
doc.activeLayer = layer;
executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);
}
adj_layer.remove();
}
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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

Link in Zwischenablage kopieren
Kopiert
Thank you for helping but I can't understand why it doesn't work for me.

Link in Zwischenablage kopieren
Kopiert
It doesn't work for you because on your original image other layers "weren't" inside Head.
Link in Zwischenablage kopieren
Kopiert
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

Link in Zwischenablage kopieren
Kopiert
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[n] == adj_layer)
{
for (++n; n < parent.layers.length; n++)
{
if (parent.layers[n].typename == "LayerSet")
{
var set = parent.layers[n];
for (var i = set.artLayers.length-1; i >= 0; i--)
{
var layer = adj_layer.duplicate(set.artLayers[i], ElementPlacement.PLACEBEFORE)
doc.activeLayer = layer;
executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);
}
adj_layer.remove();
return;
}
}
}
}
}
Link in Zwischenablage kopieren
Kopiert
Thank you r-bin, you're the BEST!!
Link in Zwischenablage kopieren
Kopiert
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?

Link in Zwischenablage kopieren
Kopiert
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[n] == adj_layer)
{
for (++n; n < parent.layers.length; n++)
{
if (parent.layers[n].typename == "LayerSet")
{
var set = parent.layers[n];
for (var i = 0; i < set.artLayers.length; i++)
{
var grouped = set.artLayers[i].grouped;
var layer = adj_layer.duplicate(set.artLayers[i], ElementPlacement.PLACEBEFORE)
doc.activeLayer = layer;
if (grouped && !layer.grouped) layer.grouped = grouped;
executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);
}
adj_layer.remove();
return;
}
}
}
}
}
Link in Zwischenablage kopieren
Kopiert
Thank you so much for this code, you are a beautiful human being! That will save me so much time ![]()
Link in Zwischenablage kopieren
Kopiert
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!
Link in Zwischenablage kopieren
Kopiert
I corrected the codes! Try again.
Link in Zwischenablage kopieren
Kopiert
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...
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
Hi does this script work with layers such as multiply and color dodge?
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
Hey Guys
This is something I need, but I get this illegal argument.
Any ideas?
Thanks
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
Link in Zwischenablage kopieren
Kopiert
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen