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

Need plugin / custom script for renaming artboards with numbering suffixes

Community Beginner ,
Feb 14, 2023 Feb 14, 2023

Hello Everyone,

I basically need to rename artboards in bulk to save time...just mostly adding numbers as suffixes to artboards.For instance,

Screenshot 2023-02-14 163154.png

 

With the attached example, the resulting artboard names would be:
1- Layer 1_Gk01
2- Layer 2_Gk02
3- Layer 3_Gk03

 

I need to rename the selected artboard with consecutive numbering suffixes from the previous artboard (not always starting from _10). I am not sure if this is possible. So I am seeking the help of photoshop wizrads here to find a fix😅. Thanks in advance.

 

 

TOPICS
Actions and scripting , Windows
4.3K
Translate
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 1 Correct answer

Community Expert , Feb 15, 2023 Feb 15, 2023

@V0ID_GUY 

 

The following script isn’t perfect, however, it is the best that I can do for now.

 

Perhaps a better script writer than me can fix the code as it also indiscriminately processes layer groups and frames (as these are all layerSets)... The isArtboard function that I hacked works when used on a single layer outside of a for loop, but doesn't work when used in a for loop?

 

Edit: 23rd Februray 2023: Code updated, it should now only rename top-level artboards, not groups or frames.

 

/*
...
Translate
Adobe
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Presuming that the layers have the correct digits in them to "borrow" for the numbering... The quickest way is to leverage an existing script, without having to create a custom script.

 

layer-edit.png

 

https://github.com/Paul-Riggott/PS-Scripts/blob/master/Layer%20Name%20Edit.jsx

 

I changed line 20 from:

 

 

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);

 

 

To:

 

 

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.2, 0.2, 0.2, 1]);

 

 

For a dark interface.

 

The regular expression find/replace can be hard-coded into the script so that you don't have to type it in each time.

 

Find:

(Layer )(\d+)

 

Replace:

Layer $2_Gk0$2

 

You would need to manually account for including/excluding the leading zero padding character.

Translate
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 Beginner ,
Feb 14, 2023 Feb 14, 2023

I appreciate your instant response, however I am a complete noob to Photoshop scripts. I was unable to grasp what you were attempting to say. Could you please assist me in detail.

Translate
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 ,
Feb 14, 2023 Feb 14, 2023
Translate
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 Beginner ,
Feb 14, 2023 Feb 14, 2023

But I dont want to always have the same number in artboard name.....will give you an example

Screenshot 2023-02-15 131740.png

If I select the top artboard (here the one with "_GK01" at the end) and run the script, it must automatically rename the below artboards as:

 

1. Image_GK01

2. File_GK02

3. Folder_GK03

 

So I am expecting a script to take the last part of the slected artboard name & rename below artboards by adding consecutive numbers to it....Hope this helps. 

Translate
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 ,
Feb 15, 2023 Feb 15, 2023

OK, as mentioned the previous find/replace method relied of the layers having the correct numbers.

 

You have mentioned renaming/numbering in bulk. You have also mentioned selected artboards, however, one screenshot had no artboards selected and the other only 1 of 3 selected... So, is this only for selected artboards, or for all artboards in the doc?

 

Is the expectation to only run the script once and all artboards are then renamed/sequentially numbered? Or would you need to run this multiple times in the documents life? If multiple times, would all layers simply be renamed/renumbered again, or do you need only new artboards renamed that don't match the current numbering and therefore require the numbers to start where the previous one finished?

 

 

Translate
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 Beginner ,
Feb 15, 2023 Feb 15, 2023

I mean that based on the selected artboards final numbering part ( _0GK1), all other artboards under the selected one in the document must be numbered sequentially/consecutively ( _0GK2, _0GK3,......so on)

 

I think that my last post explains my requirements a bit clear than the first one...So I am expecting a single script  that would work on every document (ran once per document)...I would do the renaming of the first artboard myself...the script must just start renaming consecutively after mine.

Translate
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 ,
Feb 15, 2023 Feb 15, 2023

Thanks, I think that I can (mostly) meet these requirements.

Translate
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 ,
Feb 15, 2023 Feb 15, 2023

@V0ID_GUY 

 

The following script isn’t perfect, however, it is the best that I can do for now.

 

Perhaps a better script writer than me can fix the code as it also indiscriminately processes layer groups and frames (as these are all layerSets)... The isArtboard function that I hacked works when used on a single layer outside of a for loop, but doesn't work when used in a for loop?

 

Edit: 23rd Februray 2023: Code updated, it should now only rename top-level artboards, not groups or frames.

 

/*
Rename artboards with custom prefix and sequential numbers.jsx
v1.1 - 23rd February 2023, Stephen Marsh
*/

var sequencePartTwo = activeDocument.activeLayer.name.replace(/(^.+)(_\D+)(0*)(\d+)/, "$2");
var sequenceSuffixLength = 2;
var sequencePartFour = activeDocument.activeLayer.name.replace(/(^.+)(_\D+)(0*)(\d+)/, "$4");
// Backward loop - bottom to top
// for (var i = activeDocument.layerSets.length - 1; i >= 0; i--) {
// Forward loop - top to bottom
for (var i = 0; i < activeDocument.layers.length; i++) {
    try {
        activeDocument.activeLayer = activeDocument.layers[i];
        if (activeDocument.activeLayer.typename === "LayerSet" && isArtboard() === true) {
            var sequencePartOne = activeDocument.layers[i].name.replace(/(^.+)(_\D+)(0*)(\d+)/, "$1");
            activeDocument.layers[i].name = sequencePartOne + sequencePartTwo + sequenceSuffix(sequencePartFour, sequenceSuffixLength);
            sequencePartFour++;
        }
    } catch (e) {
        alert("Error!" + "\r" + e + ' ' + e.line);
    }
}


///// Functions /////

function sequenceSuffix(num, digit) {
    var tmp = num.toString();
    while (tmp.length < digit) {
        tmp = "0" + tmp;
    }
    return tmp;
}

function isArtboard() {
    // modified from a script by greless with hints from jazz-y!
    // returns true or false
    try {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putEnumerated(stringIDToTypeID('layer'), stringIDToTypeID('ordinal'), stringIDToTypeID('targetEnum'));
        var options = executeActionGet(r);
        return options.hasKey(stringIDToTypeID('artboard')); // test for the required key
    } catch (e) {
        //alert(e);
    }
}

 

Translate
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 Beginner ,
Feb 15, 2023 Feb 15, 2023

Thank you so much😍...tested it...works goood...gonna save much of your time.

Translate
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 ,
Feb 15, 2023 Feb 15, 2023

You're welcome! As long as you don't have any top-level layer groups or frames which are not contained in artboards, you should be OK.

Translate
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 ,
Feb 23, 2023 Feb 23, 2023

I have overcome the issue with differentiating between the 3 different kinds of layerSets, so now only artboards are renamed, not groups or frames.

Translate
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
Explorer ,
May 03, 2023 May 03, 2023

we made a Photoshop plug-in that can do this. The unlimited version is 12$. 

806743DC-4B65-4BEF-9D93-27EEADEBB957.png9D39CFB6-F1AE-4CD4-AEFD-97AAFB6AE7A2.png

 

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 to rename them.

ACDB94BA-0EEB-49C2-9175-058DE034925B.png

Translate
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
Advocate ,
Jun 08, 2023 Jun 08, 2023
LATEST
Translate
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