Skip to main content
CarlyCamera
Participant
March 26, 2020
Answered

Photoshop | Creating an Action with a closed Group

  • March 26, 2020
  • 3 replies
  • 2301 views

When I create a lengthly action, I put all the steps in a New Group (or folder). I close the group, label it. I then stop my action. When I replay the action all the steps work... but the folder with all the lengthly steps is open. It doesn't close. 

 

How do I make the folder close? I want the action to play and close the folder like the image below. 

 

Instead when the action is played it doesn't close that folder. And looks like this. 

 

 

I have tried recording the action and having me close the folder before I stopped the recording. That doesn't work. 

 

It's not a big deal when you run 1 action with one open folder. But when you begin to run several actions with several folders for a lengthly action, it gets big and messy quick. 

 

Thanks for your help. 

This topic has been closed for replies.
Correct answer JJMack

you would need to record the action a little differently.   Do not create a new layer group and add layers into the group.  Instead  just create all the layers and name them that you want in the group. When the last layer you want in the grout is added that will be Photoshop targeted layer. Add the rest of the layer you added to the targeted layers.  It Is best to record this relatively using the shortcut Shift+Alt+[  for each layer added. The Shortcut add the Previous layer to the targeted layers.  Once all the layer are targeted record menu Layer>New>Group from Layers... . In the Pop-up dialog name the group. The group will be created and closed.

3 replies

Stephen Marsh
Community Expert
Community Expert
March 26, 2020

The panel menu Layer > Collapse All Groups can also be recorded or inserted into an action, however it is all or nothing.

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
March 26, 2020

you would need to record the action a little differently.   Do not create a new layer group and add layers into the group.  Instead  just create all the layers and name them that you want in the group. When the last layer you want in the grout is added that will be Photoshop targeted layer. Add the rest of the layer you added to the targeted layers.  It Is best to record this relatively using the shortcut Shift+Alt+[  for each layer added. The Shortcut add the Previous layer to the targeted layers.  Once all the layer are targeted record menu Layer>New>Group from Layers... . In the Pop-up dialog name the group. The group will be created and closed.

JJMack
CarlyCamera
Participant
March 26, 2020

Brilliant!!! It worked! Thank you so much JJMACK!!!

Stephen Marsh
Community Expert
Community Expert
July 29, 2021

 

Agreed, many seemingly obvious things are missing from actions or even scripting.

 

On the align to canvas, you can select all and align to selection, which achieves the same result and yes it is a workaround.

 

The action based "hack" that I just tested to collapse only the current selected layer set/group is absurd, but I may just look into it for "fun" as it does work...

 

 

Convert SO to Layers (Introduced in Photoshop 21.0, November 2019 release):

https://helpx.adobe.com/photoshop/using/create-smart-objects.html

 

However, I would of course just use the script below unless this had to be purely action based.

 


 

A script to collapse the current selected layer set/group here:

/*
Expand / collapse a group via JavaScript?
https://community.adobe.com/t5/photoshop-ecosystem/expand-collapse-a-group-via-javascript/m-p/7286298
By Vova_p, 16th February 2016

Modified by Stephen Marsh, 29th July 2021
https://gist.github.com/MarshySwamp/a39e3e1efee41174b3b92ee68c40fcd8
*/

#target photoshop

if (app.documents.length > 0) {

    if (app.activeDocument.activeLayer.typename === "LayerSet" && app.activeDocument.activeLayer.layers.length > 0) {
        collapseSelectedGroup();
    } else {
        //alert("This layer type is NOT a layer set/group")
    }

    function collapseSelectedGroup() {
        // Collapse selected layer group/set
        // remember name of group
        var groupname = app.activeDocument.activeLayer.name;
        // This part from  Script Listener - ungroup group
        var idungroupLayersEvent = stringIDToTypeID("ungroupLayersEvent");
        var desc14 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref13 = new ActionReference();
        var idLyr = charIDToTypeID("Lyr ");
        var idOrdn = charIDToTypeID("Ordn");
        var idTrgt = charIDToTypeID("Trgt");
        ref13.putEnumerated(idLyr, idOrdn, idTrgt);
        desc14.putReference(idnull, ref13);
        executeAction(idungroupLayersEvent, desc14, DialogModes.NO);
        // This part from  Script Listener - group selected layers
        var idMk = charIDToTypeID("Mk  ");
        var desc15 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref14 = new ActionReference();
        var idlayerSection = stringIDToTypeID("layerSection");
        ref14.putClass(idlayerSection);
        desc15.putReference(idnull, ref14);
        var idFrom = charIDToTypeID("From");
        var ref15 = new ActionReference();
        var idLyr = charIDToTypeID("Lyr ");
        var idOrdn = charIDToTypeID("Ordn");
        var idTrgt = charIDToTypeID("Trgt");
        ref15.putEnumerated(idLyr, idOrdn, idTrgt);
        desc15.putReference(idFrom, ref15);
        executeAction(idMk, desc15, DialogModes.NO);
        // Recall group name
        app.activeDocument.activeLayer.name = groupname;
    }
} else {
    alert('A document must be open to use this script!');
}
John T Smith
Community Expert
Community Expert
March 26, 2020

Adobe currently has 23 programs included in a full Cloud subscription
Please post the name of the Adobe program you use so a Moderator may move this message to that forum

CarlyCamera
Participant
March 26, 2020

Photoshop

 

[To find a forum for your program please start at Adobe Support Community]
[Moving from generic Start/Help forum to the specific Program forum... Mod]