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

Merge group by name

Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Hello.

 

I want to merge these groups that have similar names
And then do the naming correctly, like the sample image

 

For example: Merge group :

"1-Black copy" & "1-Black" and rename to "1-Black"
"2-Navy Blue copy" & "2-Navy Blue" and rename to "2-Navy Blue"
"3-Crimson copy" & "3-Crimson" and rename to "3-Crimson"
"4-Vidas Blue copy" & "4-Vidas" Blue" and rename to "4-Vidas"

 

Thank you.

 

Merge together.jpg

 

 

TOPICS
Actions and scripting

Views

1.6K

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 2 Correct answers

LEGEND , Jun 23, 2021 Jun 23, 2021

 

sTT = stringIDToTypeID
dsc = new ActionDescriptor()
//	lSs = activeDocument.layerSets;
lSs = activeDocument.activeLayer.layerSets;
(setsToMerge = Array().slice.call(lSs)).sort()
while(lengthOfGroups = setsToMerge.length) {
	if (cndtn = !(lengthOfGroups % 2)) ref = new ActionReference()
	ref.putName(sTT('layer'), nme = setsToMerge.shift().name); if (!cndtn) {
		dsc.putReference(sTT('null'), ref); executeAction(sTT('select'), dsc)
		runMenuItem(sTT('ungroupLayersEvent')); (ref1 = new ActionRefer
...

Votes

Translate

Translate
Community Expert , Jun 23, 2021 Jun 23, 2021

You can select more than one Group in a action however you can not select groups with similar names the exact name must be recorded in the Action and The Action may not work correctly if there are more than one group with the Recorded Name in the Document the Action is played on only one of the groups  the  correct will be seleted.

Capture.jpg

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

You would need to script that processing.  That process requires the use of logic.  Actions are recorded steps all setting are recorded fixed setting.   You also have to be careful using names for names may not be unique

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

My problem is that I can not select 2 groups using action, only one layer is selected. If this problem is solved, I have no problem using action with fixed setting...

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

LATEST

You can select more than one Group in a action however you can not select groups with similar names the exact name must be recorded in the Action and The Action may not work correctly if there are more than one group with the Recorded Name in the Document the Action is played on only one of the groups  the  correct will be seleted.

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
Community Expert ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Why did you add » copy« in the first place? 

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

These layers are not the same, they were not actually copied.
It is copied from different layers with the same type of name and must be merged together.

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

But why did you add » copy« to the names? 

One can turn that off … 

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

 

sTT = stringIDToTypeID
dsc = new ActionDescriptor()
//	lSs = activeDocument.layerSets;
lSs = activeDocument.activeLayer.layerSets;
(setsToMerge = Array().slice.call(lSs)).sort()
while(lengthOfGroups = setsToMerge.length) {
	if (cndtn = !(lengthOfGroups % 2)) ref = new ActionReference()
	ref.putName(sTT('layer'), nme = setsToMerge.shift().name); if (!cndtn) {
		dsc.putReference(sTT('null'), ref); executeAction(sTT('select'), dsc)
		runMenuItem(sTT('ungroupLayersEvent')); (ref1 = new ActionReference()).putClass
		(lS = sTT('layerSection')); (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
		(ref2 = new ActionReference()).putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum'))
		dsc1.putReference(sTT('from'), ref2); (dsc2 = new ActionDescriptor()).putString(sTT('name'), nme)
		dsc1.putObject(sTT('using'), lS, dsc2), executeAction(sTT('make'), dsc1)
	}
}

 

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Thank you very much.

The script worked properly, there is only one problem.

I think if the layers are a subset of another group it will show the following error message:


Error 21: undefined is not an object.
Line: 7
-> ref.putName(sTT('layer'), nme = pair.shift().name);

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Before you replied I updated script to other version you may try. See if you have same error.

What do you mean layers are subset of another group - are you referring to original image?

I understand your screenshot does not show upper containers, then you have to change:

 

lSs = activeDocument.layerSets;

 

to:

 

lSs = activeDocument.activeLayer.layers;

 

Ps. I added it now to the script. Remember to select main group before running!

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

This worked fine but kept a copy of the previous group 🙂

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 ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

What does that mean? For me everything works fine. Post before / after screenshots.

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

After.jpg

Before:

Before.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
LEGEND ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

You made mistake, the first layerSet is without copy: "1-Black". Change it to "1-Black copy".

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
Explorer ,
Jun 23, 2021 Jun 23, 2021

Copy link to clipboard

Copied

Oh! That's right!

Thank you very much.

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