What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Action to collapse layer groups


evren

Well-Known Member
Messages
137
Likes
19
i have about 50 psd files, they all contain a layer group named "LINE" and these groups are all in expanded form..

how can i record an action to have these layer groups called "LINE" collapsed in all of my psd files?

i tried to record an action while i collapse the layer group by using my mouse, but i think photoshop does not record mouse clicks..

any ideas?
 
Do you want this specific group closed or all groups closed? It can be done with a script. I don't think it can be done with an Action
John Wheeler
 
Do you want this specific group closed or all groups closed? It can be done with a script. I don't think it can be done with an Action
John Wheeler

actually i want all the groups to be closed..
not possible with an action?
i have never used a script, no idea how it works..
 
Last edited:
Hi @evren
Turns out this is a simple script. Its only simple because many AI engines can generate Photoshop scripts. As it turns out there is an internal PS command that does this yet PS does not make it a menu option (I have no clue why).

Here is a dropbox link with the script file that collapses all groups independent of group name. The Layer stack just needs to be active in the active document.

https://www.dropbox.com/scl/fi/tn18...oups.jsx?rlkey=hjrn93sm2jsk4vaxlhpcrihz0&dl=0

You save the file on your computer and run the script with the command File > Scripts > Browse and select this jsx file. Running that file will collapse all groups. I've tested it and I have had no problems. You must have Photoshop 2020 or later for it to work. That command can be recorded in an Action as well it you want to do a Batch command on a large number of files.

Give it a try and let us know how it works for you
John Wheeler
 
first i tried with a single file then i recorded an action and applied it to all of the psd's
worked great, thank you very much cheers :)

this was my first time using a script..
is there a website i can find other scripts to see what else they can do?
 
first i tried with a single file then i recorded an action and applied it to all of the psd's
worked great, thank you very much cheers :)

this was my first time using a script..
is there a website i can find other scripts to see what else they can do?
You're welcome @evren
I have not perused scripts ' websites in years, yet a starting point for you might be https://www.ps-scripts.com/

One way to think about scripts is that they have low-level access to the innards of PS so that almost anything can be automated. Writing scripts is part of software development, and what accompanies it, especially for more complex capabilities, is verifying and debugging the code.

I usually use scripts in situations where I have a repeated need in PS that generally requires some overhead each time. Feels really good when you get one that works.

Ages ago, I invested some time in writing scripts, but it wasn't a great return on my investment until I started using AI to write them. I would recommend just asking an AI engine, "Write a Photoshop script that collapses all groups in the Layer Stack of the active Document," and see the result you get. It's often that simple. In your case, the code was short and worked the first time.
John Wheeler
 
actions and scripts are life saviours when u have repeating tasks..

may i ask which ai engine u use to write a script and is it free?
 
The free version of ChatGPT can create scripts.
Keep in mind that ChatGPT or any AI is not "all knowing" and will give an answer that might work, yet not the most succinct or elegant approach.
I tried to get the free ChatGPT version to create a script to close all groups, and it did, but the script was initially much longer. I asked it if it could make it shorter, and it did, yet it did not know how to implement the internal PS command, which is the shortest. When I asked, "How about using the collapseAllgroupsevent capability?" it finally created the short version.

I suspect that any of the versions to collapse all groups may have worked, yet the longer the code is, the more debugging you might face. ChatGPT can debug its own code when you guide it by explaining how the code failed.

So I am saying your mileage may vary, yet when you get a working script, no matter how long the code, it sure beats doing it by hand.
John Wheeler
 

Back
Top