• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applying adjustment layer to multiple layers

New Here ,
Mar 12, 2019 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

TOPICS
Actions and scripting

Views

14.7K

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
community guidelines

correct answers 1 Correct answer

Valorous Hero , Mar 14, 2019 Mar 14, 2019

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

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 12, 2019 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

Votes

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
community guidelines
New Here ,
Mar 13, 2019 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.

Votes

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
community guidelines
Valorous Hero ,
Mar 12, 2019 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[i], ElementPlacement.PLACEBEFORE)
		doc.activeLayer = layer;
		executeAction(stringIDToTypeID("mergeLayersNew"), undefined, DialogModes.NO);
		}
	adj_layer.remove();
	}

Votes

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
community guidelines
New Here ,
Mar 13, 2019 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

Votes

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
community guidelines
Advocate ,
Mar 13, 2019 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

Votes

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
community guidelines
New Here ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

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

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

Votes

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
community guidelines
LEGEND ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

It doesn't work for you because on your original image other layers "weren't" inside Head.

Votes

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
community guidelines
Community Expert ,
Mar 13, 2019 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

Votes

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
community guidelines
Valorous Hero ,
Mar 14, 2019 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[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;
					}
				}
			}
		}
	}

Votes

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
community guidelines
New Here ,
Mar 14, 2019 Mar 14, 2019

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
May 07, 2019 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

Votes

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
community guidelines
Valorous Hero ,
May 07, 2019 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[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;
					}
				}
			}
		}
	}

Votes

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
community guidelines
New Here ,
May 07, 2019 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

Votes

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
community guidelines
New Here ,
Nov 27, 2019 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!

 

Votes

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
community guidelines
LEGEND ,
Oct 23, 2021 Oct 23, 2021

Copy link to clipboard

Copied

I corrected the codes! Try again.

Votes

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
community guidelines
New Here ,
Jul 09, 2020 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...

 

Votes

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
community guidelines
LEGEND ,
Oct 23, 2021 Oct 23, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Beginner ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Valorous Hero ,
Mar 13, 2019 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

Votes

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
community guidelines
New Here ,
Dec 04, 2020 Dec 04, 2020

Copy link to clipboard

Copied

Hey Guys

This is something I need, but I get this illegal argument.

Any ideas?

Thanks

Screenshot 2020-12-04 at 17.03.59.png

Votes

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
community guidelines
LEGEND ,
Oct 23, 2021 Oct 23, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines
New Here ,
Mar 17, 2020 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 

Votes

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
community guidelines
LEGEND ,
Oct 23, 2021 Oct 23, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Expert ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines