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

Photoshop layer groups with incremental numbers

Engaged ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

The Photoshop action creates the CC 01 layer group with the Curves 1 and the Hue Saturation  1 adjustment layers inside the CC 01 layer group. 

 

Typically, it is necessary to add multiple CC 01 layer groups to edit the Photoshop file. 

To stay organized, it would be useful to automatically increment the CC 01 layer group number by 1 every time the action runs. 

 

What is the simplest way to achieve this with a script?

I’m thinking the script should follow these steps and repeat steps with adjustment layers

 

Crete variable CCcnt

Assign value CCcnt = “CC 01”

 

Check if CC 01 layer group exists

If false

Run action to make CC 01 layer grp

Exit script

 

If true

Run action to make CC 01 layer grp

Rename CC 01 to CC 02 with the script 

Get the last two characters of the layer group  name

Increment the last character by 1

Get the new layer name CC 02

Assing to CC 02 variable CCcnt

Exit script

TOPICS
Actions and scripting

Views

299

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

Community Expert , Jul 16, 2022 Jul 16, 2022

Ok, so try inserting this script into your action after you make a new layer group, but befor you add any other layers. You want the layer group that you want to add to the next number selected.

 

#target photoshop
var doc = activeDocument;
var curLay =doc.activeLayer;
var layPar = curLay.parent;
var numA = new Array()

for(var i=0;i<layPar.layers.length;i++){
    if(layPar.layers[i].typename == 'LayerSet'){
        if(!isNaN (Number(layPar.layers[i].name.substr (3, 2)))){
            numA.push(
...

Votes

Translate

Translate
Engaged , Jul 17, 2022 Jul 17, 2022

Thank you very much, the script works great!

I had to do a minor adjustment. Recreate the action with the folder name CC 00 and change the variable in the script to CC 00.  Without this change, the script creates the folder CC 02. With the change, it creates the folder CC 01.

Your help is greatly appreciated Chuck!

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Which action are you talking about? One that you created? Are these layer groups at the top level, meaning that they're not inside another 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
Engaged ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Yes, I created the Photoshop acion to make the CC 01 layer group.

The action runs at the top level in the layer palette and sometimes in subfolders.

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 ,
Jul 16, 2022 Jul 16, 2022

Copy link to clipboard

Copied

Ok, so try inserting this script into your action after you make a new layer group, but befor you add any other layers. You want the layer group that you want to add to the next number selected.

 

#target photoshop
var doc = activeDocument;
var curLay =doc.activeLayer;
var layPar = curLay.parent;
var numA = new Array()

for(var i=0;i<layPar.layers.length;i++){
    if(layPar.layers[i].typename == 'LayerSet'){
        if(!isNaN (Number(layPar.layers[i].name.substr (3, 2)))){
            numA.push([Number(layPar.layers[i].name.substr (3, 2)),i])
            }     
        }
    }
numA.sort();
numA.reverse();
if(numA.length ==0){curLay.name = 'CC 01'}
else{
    var nextNum = 101 + numA[0][0]
    curLay.name = 'CC ' + nextNum.toString().substr (1, 2)
    }

 

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
Engaged ,
Jul 17, 2022 Jul 17, 2022

Copy link to clipboard

Copied

Thank you very much, the script works great!

I had to do a minor adjustment. Recreate the action with the folder name CC 00 and change the variable in the script to CC 00.  Without this change, the script creates the folder CC 02. With the change, it creates the folder CC 01.

Your help is greatly appreciated Chuck!

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 ,
Jul 17, 2022 Jul 17, 2022

Copy link to clipboard

Copied

Glad it's working. Odd, I thought it did create the CC 01 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
Engaged ,
Jul 17, 2022 Jul 17, 2022

Copy link to clipboard

Copied

LATEST

I am not sure why initially the script created the folder CC 02 in my system.

It could be related to the action structure. The original action had the make group step at the end of the action after the adjustment layers. When I moved the make group step to the beginning of the action it create the CC 002 group. The workaround was to edit the action to make the group CC 00 and change the variable to CC 00 in the script.

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