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.
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
...
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.
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
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Why did you add » copy« in the first place?
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.
Copy link to clipboard
Copied
But why did you add » copy« to the names?
One can turn that off …
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)
}
}
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);
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!
Copy link to clipboard
Copied
This worked fine but kept a copy of the previous group 🙂
Copy link to clipboard
Copied
What does that mean? For me everything works fine. Post before / after screenshots.
Copy link to clipboard
Copied
Before:
Copy link to clipboard
Copied
You made mistake, the first layerSet is without copy: "1-Black". Change it to "1-Black copy".
Copy link to clipboard
Copied
Oh! That's right!
Thank you very much.