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

P: Rename multiple layers in one go

Community Beginner ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

Renaming each individual layer is rather slow, what if we can rename all selected layers at once?

Idea Released
TOPICS
macOS , Windows

Views

13.0K

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 1 Correct answer

Adobe Employee , Mar 22, 2012 Mar 22, 2012
You can do this in Photoshop CS6.

Double-Click a layer name to rename it, then hit tab to put focus on the next layer to rename it....and so on.

Note: Shift + tab moves up the layer stack, tab moves down the layer stack.

Votes

Translate

Translate
21 Comments
Adobe Employee ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

You can do this in Photoshop CS6.

Double-Click a layer name to rename it, then hit tab to put focus on the next layer to rename it....and so on.

Note: Shift + tab moves up the layer stack, tab moves down the layer stack.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

Ahhhhh. *Leans back in chair, happy*

Votes

Translate

Translate

Report

Report
Adobe Employee ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

Is that what you were looking for? I couldn't see wanting to name 20 layers all the same name. 😉

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

Yes... I know what you mean though but there are instances where I've needed to name things the same.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

I need to do this though. Is there a quick way to do it without having to copy and past over and over again?

Votes

Translate

Translate

Report

Report
Community Expert ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

quote

I need to do this though. Is there a quick way to do it without having to copy and past over and over again?

 

@Julien5C96 

 

You can do this using a free script from Paul Riggott. The find is regular expression based, so .+ will find the entire layer name:

 

pr-layer-name-editor.gif

 

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

 

Change line 20 from:

 

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

 

to something like:

 

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

 

For a "dark mode" interface.

 

EDIT: Or perhaps even better:

 

var myBrush = g.newBrush(g.BrushType.THEME_COLOR, "appDialogBackground");

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Jan 24, 2022 Jan 24, 2022

Copy link to clipboard

Copied

The following script will probably be easier to use if you don't know regular expressions:

 

/*
Rename Selected Layers.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/trouble-with-photoshop-layer-masks/td-p/12698065
Stephen Marsh, 25th January 2022 - v1.0
*/

#target photoshop

function main() {

    var promptString = prompt("New layer name:", "");

    // Optionally select all layers, uncomment if required
    //app.runMenuItem(stringIDToTypeID('selectAllLayers'));

    /***** 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);
    /***** Process Selected Layers from Jazz-y *****/

        if (app.documents.length > 0) {

            app.activeDocument.activeLayer.name = promptString;

        } else {
            alert("You must have a document open!");
        }
    }
}
app.activeDocument.suspendHistory("Rename selected layers", "main()");

 

 

 

Votes

Translate

Translate

Report

Report
Community Beginner ,
Jan 25, 2022 Jan 25, 2022

Copy link to clipboard

Copied

Thank you. Does this work with renaming artboards as well?

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

Hi Stephen your reamer script is great.

But what do i need to add to make it add incremental numbers to each of the layers?

thanks

im struggling with this

 

ian

Votes

Translate

Translate

Report

Report
Community Expert ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

quote

Hi Stephen your reamer script is great.

But what do i need to add to make it add incremental numbers to each of the layers?

thanks

im struggling with this

 

ian

 

rename.png

A different script, not my code. The incremental number is added as a suffix, you may wish to put a space, hyphen, underscore or another at the end of the name new layer name as the sequential number is added at the end. Works on selected layers, the start number can be changed which is nice. Renames from the bottom of the panel up by default:

 

#target photoshop
app.bringToFront();
main();
function main(){
if(!documents.length) return;
var selectedLayers = getSelectedLayersIdx();
var win = new Window( 'dialog', '' ); 
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.2, 0.2, 0.2, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"}); 
win.g1 = win.p1.add('group');
win.g1.orientation = "row";
win.title = win.g1.add('statictext',undefined,'Rename Layers');
win.title.alignment="fill";
var g = win.title.graphics;
g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
win.g5 =win.p1.add('group');
win.g5.orientation = "column";
win.g5.alignChildren='left';
win.g5.spacing=10;
win.g5.st1 = win.g5.add('statictext',undefined,'New layer name');
win.g5.et1 = win.g5.add('edittext'); 
win.g5.et1.preferredSize=[250,20];
win.g10 =win.p1.add('group');
win.g10.orientation = "row";
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Serial Number'); 
win.g10.et1 = win.g10.add('edittext',undefined,'1');
win.g10.et1.preferredSize=[50,20];
win.g10.et1.onChanging = function() { 
  if (this.text.match(/[^\-\.\d]/)) { 
    this.text = this.text.replace(/[^\-\.\d]/g, ''); 
  } 
};
win.g10.st1 = win.g10.add('statictext',undefined,'Length'); 
var nums=[2,3,4,5];
win.g10.dl1 = win.g10.add('dropdownlist',undefined,nums);
win.g10.dl1.selection=0;
win.g15 =win.p1.add('group');
win.g15.orientation = "row";
win.g15.alignment='fill';
win.g15.cb1 = win.g15.add('checkbox',undefined,'Reverse layer order');
win.g100 =win.p1.add('group');
win.g100.orientation = "row";
win.g100.alignment='center';
win.g100.spacing=10;
win.g100.bu1 = win.g100.add('button',undefined,'Rename');
win.g100.bu1.preferredSize=[120,30];
win.g100.bu2 = win.g100.add('button',undefined,'Cancel');
win.g100.bu2.preferredSize=[120,30];
win.g100.bu1.onClick=function(){
if(win.g5.et1.text == ''){
    alert("No layer name has been entered!");
    return;
    }
win.close(0);
if(win.g15.cb1.value) selectedLayers.reverse();
for(var a in selectedLayers){
    var LayerName = win.g5.et1.text + zeroPad((Number(win.g10.et1.text)+Number(a)), Number(win.g10.dl1.selection.text));
    putLayerNameByIndex(Number(selectedLayers[a]), LayerName );
    }
}
win.center();
win.show(); 
}
function getSelectedLayersIdx(){ 
      var selectedLayers = new Array; 
      var ref = new ActionReference(); 
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
      var desc = executeActionGet(ref); 
      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){ 
         desc = desc.getList( stringIDToTypeID( 'targetLayers' )); 
          var c = desc.count 
          var selectedLayers = new Array(); 
          for(var i=0;i<c;i++){ 
            try{ 
               activeDocument.backgroundLayer; 
               selectedLayers.push(  desc.getReference( i ).getIndex() ); 
            }catch(e){ 
               selectedLayers.push(  desc.getReference( i ).getIndex()+1 ); 
            } 
          } 
       }else{ 
         var ref = new ActionReference(); 
         ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" )); 
         ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
         try{ 
            activeDocument.backgroundLayer; 
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1); 
         }catch(e){ 
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))); 
         } 
     var vis = app.activeDocument.activeLayer.visible;
        if(vis == true) app.activeDocument.activeLayer.visible = false;
        var desc9 = new ActionDescriptor();
    var list9 = new ActionList();
    var ref9 = new ActionReference();
    ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    list9.putReference( ref9 );
    desc9.putList( charIDToTypeID('null'), list9 );
    executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO );
    if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift();
        app.activeDocument.activeLayer.visible = vis;
      } 
      return selectedLayers; 
};
function zeroPad(n, s) { 
n = n.toString(); 
while (n.length < s) n = '0' + n; 
return n; 
};
function putLayerNameByIndex( idx, name ) {
     if( idx == 0 ) return;
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putIndex( charIDToTypeID( 'Lyr ' ), idx );
    desc.putReference( charIDToTypeID('null'), ref );
        var nameDesc = new ActionDescriptor();
        nameDesc.putString( charIDToTypeID('Nm  '), name );
    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), nameDesc );
    executeAction( charIDToTypeID( 'slct' ), desc, DialogModes.NO ); 
    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}

 

 

This one renames all layers, not selected:

 

https://morris-photographics.com/photoshop/scripts/rename-layers.html

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

@e-onn 

 

The previous script renames all selected, variable-named layers to a common, static name + incremental number suffix.

 

For added flexibility, I have adapted this code to either prefix or suffix the incremental numbering without changing the original variable layer name.

 

Add Number Prefix to Selected Layers:

 

// Code removed due to error

 

 

Add Number Suffix to Selected Layers:

 

// Code removed due to error

 

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

Thanks so much @Stephen_A_Marsh  this works brilliant.

 

Votes

Translate

Translate

Report

Report
Explorer ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

Check out our new plugin available on the CC MarketPlace

https://adobe.com/go/cc_plugins_discover_plugin?pluginId=c36e02fb&workflow=share

 

It greatly speeds up the process of selecting and renaming layers. And can also perform other batch process that have always been a big pain when working with a large number of layers.

 

The free version is limited to 5 actions. The paid version is 12$.

Votes

Translate

Translate

Report

Report
Explorer ,
Apr 20, 2023 Apr 20, 2023

Copy link to clipboard

Copied

The free version is limited to 5 actions. The paid version is 12$.

 

select.pngbatch.pngedit.pngpreview.pnghistory.png

Votes

Translate

Translate

Report

Report
Explorer ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

Gotta say REALLY disappointed with Swift, there is no obvious warning that it has only 5 tries before it dies - so after trying to figure it out without killing my project, it suddenly points out that it is now dead and I need to PAY for it to continue.

On the adobe site it says FREE... I saw nothing saying 5 butons presses...

Now I'm completely cool with being asked to pay for it but it's a bit rum when you fiddle with it and then it stops and asks for money. Without a heads up.

Deleted - moved on

Chris

Votes

Translate

Translate

Report

Report
Explorer ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

Sorry to hear you are having a probem. It does say in the discription of the Trial version that its limited to 5 actions. But maybe it would be a good idea to have a dialong box at the start as well.

 

I will add that soon.

Votes

Translate

Translate

Report

Report
Explorer ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

Fair enough, apologies for not spotting the stuff in the description box.

 

It most certainly isn't my call but 5 clicks seems a little bit restrictive, but I'm sure there are good business reasons for it.

 

Cheers

 

Chris

Votes

Translate

Translate

Report

Report
Explorer ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

I think you are right. I'll make some changes to the trial next week.

I did not really make the plug-in for money I made it for my own company. We save a lot of time using it. Send us a mail and I can help worth the Version you have.

Votes

Translate

Translate

Report

Report
Explorer ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

I didnt spend too much time with it, but it looked pretty impressive...

Votes

Translate

Translate

Report

Report
New Here ,
Dec 23, 2023 Dec 23, 2023

Copy link to clipboard

Copied

Is thera a way to rename multiple groups?

Votes

Translate

Translate

Report

Report
Community Expert ,
Dec 23, 2023 Dec 23, 2023

Copy link to clipboard

Copied

LATEST

@Alenz wrote:

"Is thera a way to rename multiple groups?"

 

Try the various scripts in this topic, arboards/layers/groups should all be interchangeable unless a specific script is targeting a specific layer kind.

Votes

Translate

Translate

Report

Report