Copy link to clipboard
Copied
Is it possible to group all selected layers individually? Each layer would remain within the respective group. All help will be treasured.
CC 2018:
...function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'));
cnt = (lst = executeActionGet(ref).getList(sTT('targetLayersIDs'))).count
for(i = 0; i < cnt;) {
id = lst.getReference(i++).getIdentifier();
(ref1 = new ActionReference()).putClass(sTT('layerSection'));
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putIdentifier(sTT('layer'), id)
ds
Try this:
#target photoshop
function main() {
///// Process selected layers - from jazz-y /////
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
sel = new ActionReference();
for (var i = 0; i < lrs.count; i++) {
sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifie
...
Copy link to clipboard
Copied
CC 2018:
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'));
cnt = (lst = executeActionGet(ref).getList(sTT('targetLayersIDs'))).count
for(i = 0; i < cnt;) {
id = lst.getReference(i++).getIdentifier();
(ref1 = new ActionReference()).putClass(sTT('layerSection'));
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putIdentifier(sTT('layer'), id)
dsc1.putReference(sTT('from'), ref2);
nme = executeActionGet(ref2).getString(sTT('name'));
(dsc2 = new ActionDescriptor()).putString(sTT('name'), nme)
dsc1.putObject(sTT('using'), sTT('layerSection'), dsc2)
executeAction(sTT('make'), dsc1)
}
Copy link to clipboard
Copied
Phenomenal your script Kukurykus
You are a genius. Thank you.
Copy link to clipboard
Copied
Great, thanks !
Copy link to clipboard
Copied
How do I add the script into Photoshop 2019? I tried copying and pasting it into a text editor, saving as .jsx and loading it from the script menu but it just gives me a syntax error. Hoping to get this working because it's the only solution I've found on the web for making groups for each layer, and it would greatly speed up my process. Thanks in advance!
Copy link to clipboard
Copied
I don't use Mac, but there you have to change format when saving .jsx script in text editor. Make research.
Copy link to clipboard
Copied
I'm happy to report I got it working just before I went to bed last night. Here is the solution in case anyone else runs across the problem. I was using 'textedit' to try and save the .jsx file and on the Mac this does not save it properly with that app. I did research and found I should use theAdobe Extendscript Toolkit CC to create the .jsx file. Because it is no longer supported I needed to find this link on how to locate and install the Toolkit (You MUST have a CC account or it will not show up in Creative Cloud) :
Adobe Extendscript Toolkit CC download for macOS 10.13.2
After installing the toolkit I simply pasted your code into it, it auto formatted everything, save as .jsx and put it in the Photoshop scripts folder, worked like a charm! Thank you so much for all you do expanding the functionality of Photoshop. It will save me tons of work and time!
Copy link to clipboard
Copied
You don't have to use ESTK for this small operation. Just you can do what I suggested by message.
Copy link to clipboard
Copied
Apple TextEdit has two modes, a plain text mode and a rich text mode, scripts need the plain text mode. You'll likely need to fight with it and manually remove the double .jsx.txt extension and replace with .jsx
I personally prefer BBEdit on the Mac over TextEdit for plain text editing, while Atom is another popular choice.
Copy link to clipboard
Copied
Hi all,
Is it possible to make a script or action that both group and name the group the file name at the same time?
Example:
Layer01
Layer02
Layer02
I want to group them and name each group the layer names.
(exactly the same name as the layer or image)
Group name:
Layer01
Layer02
Layer03
Copy link to clipboard
Copied
Try this:
#target Photoshop
// community.adobe.com/t5/Photoshop/Action-Script-to-group-layers-and-naming/td-p/10635514
// Select all layers - Except Background "Image" Layer
app.runMenuItem(stringIDToTypeID('selectAllLayers'));
/*
// Select all layers...
var actionDescriptor = new ActionDescriptor();
var actionReference = new ActionReference();
actionReference.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
actionDescriptor.putReference( charIDToTypeID( "null" ), actionReference );
executeAction( stringIDToTypeID( "selectAllLayers" ), actionDescriptor, DialogModes.NO );
*/
/*
// Select all layers
// =======================================================
var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
var desc14 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref8 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref8.putEnumerated( idLyr, idOrdn, idTrgt );
desc14.putReference( idnull, ref8 );
executeAction( idselectAllLayers, desc14, DialogModes.NO );
*/
// community.adobe.com/t5/Photoshop/Group-Selected-Layers/td-p/9983092#10555610
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'));
cnt = (lst = executeActionGet(ref).getList(sTT('targetLayersIDs'))).count
for(i = 0; i < cnt;) {
id = lst.getReference(i++).getIdentifier();
(ref1 = new ActionReference()).putClass(sTT('layerSection'));
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putIdentifier(sTT('layer'), id)
dsc1.putReference(sTT('from'), ref2);
nme = executeActionGet(ref2).getString(sTT('name'));
(dsc2 = new ActionDescriptor()).putString(sTT('name'), nme)
dsc1.putObject(sTT('using'), sTT('layerSection'), dsc2)
executeAction(sTT('make'), dsc1)
}
Copy link to clipboard
Copied
Hi, thanks for the script! But could you help me? I want to add a mask to the name. To rename the group like this: [slovo:name_layer]
Copy link to clipboard
Copied
Could you help me to help you by providing a before and after cropped screenshot example of the layers panel? It is not clear to me what you want to do. Thanks!
Copy link to clipboard
Copied
Hi there,
I've found this similar discussion that might be able to help you with your query: Saving multiple files with group name Photoshop
Let us know how it goes.
Thanks,
Akash
Copy link to clipboard
Copied
Helo!
I need script that will make group from a layer and another group from that group with prefixes.
for example result will look like this:
is that possible?
Copy link to clipboard
Copied
@aleksanderk54154416 – Something like this?
var layerName = activeDocument.activeLayer.name;
setFromLayer("[Merge]" + layerName);
setFromLayer("[Bone]" + layerName);
function setFromLayer(layNme) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass( s2t( "layerSection" ));
descriptor.putReference( s2t( "null" ), reference );
reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( s2t( "from" ), reference2 );
descriptor2.putString( s2t( "name" ), layNme );
descriptor.putObject( s2t( "using" ), s2t( "layerSection" ), descriptor2 );
executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}
A prompt could be added so that you type in the name of the prefix into a GUI, rather than having it hard-coded.
Copy link to clipboard
Copied
It works man! I am going to cry now :))
thanx a lot
Copy link to clipboard
Copied
but, but 🙂 can you make it to work for each layer when selected multiple layers?
Copy link to clipboard
Copied
but, but 🙂 can you make it to work for each layer when selected multiple layers?
By @aleksanderk54154416
Ah, scope creep!
Copy link to clipboard
Copied
Try this:
#target photoshop
function main() {
///// Process selected layers - from jazz-y /////
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
sel = new ActionReference();
for (var i = 0; i < lrs.count; i++) {
sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
(r = new ActionReference()).putIdentifier(s2t('layer'), p);
(d = new ActionDescriptor()).putReference(s2t("target"), r);
executeAction(s2t('select'), d, DialogModes.NO);
//////////
var layerName = activeDocument.activeLayer.name;
setFromLayer("[Merge]" + layerName);
setFromLayer("[Bone]" + layerName);
///// Functions /////
function setFromLayer(layNme) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass(s2t("layerSection"));
descriptor.putReference(s2t("null"), reference);
reference2.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
descriptor.putReference(s2t("from"), reference2);
descriptor2.putString(s2t("name"), layNme);
descriptor.putObject(s2t("using"), s2t("layerSection"), descriptor2);
executeAction(s2t("make"), descriptor, DialogModes.NO);
}
}
}
app.activeDocument.suspendHistory("Undo Script", "main()");
Copy link to clipboard
Copied
Yesss! Thats it! Thank you! No more scope creeping 🙂
Copy link to clipboard
Copied
we made a Photoshop plug-in that can do this. The unlimited version is 12$.
Full Version (12$):
https://exchange.adobe.com/apps/cc/c36e02fb/swift
Trial Version (Limited to 5 Actions):
https://exchange.adobe.com/apps/cc/412c1dcd/swift-trial-version
Its also a big help with getting the layers selected.