What's new

Actions Help with Copying Layer Name to Group Name for an Action


As part of an action I'm trying to create, I need to be able to copy a specific layer's name and then use that name as the name of the new group I will create with that layer in it.

Is there a way to do that?

Thanks so much!

(Learned a bunch already here.)
no sure of your question but once you create the new group folder just rename it what you want within the layers palette, could you be more specific?
Thanks, iDad. I will try.

I want to do what you described, but I need to be able to do it automatically - to be able to program it into my action. With other things I can use keyboard shortcuts or menus to record into my actions, but I can't find a shortcut or menu item for copying a layer's name and/or pasting that name as a group's name.

Is there such a thing as a hotkey/keyboard shortcut or menu combination that I can use to make this process automatic? Or is there a way I can record this process of copying/pasting layer names so that it will be automatic in my action?

I hope this is more clear.

Thanks again!
I believe the member Yutosi addressed this issue, let me see if I can find his thread..myself not very good with actions
All sort of howtos to save styles but can not find Actions for it,........actions throw me for a loop...good luck perhaps another here will have your answer

Paul MR

The Script Master
What you are trying to do is not possible with just an action, but all is not lost, a script can do this and can be called from an action.
This script requires that the layer you want to be placed inside the new layerset be the active layer.
Download, unzip and place the script into the relevant folder:
PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts
MAC: <hard drive>/Applications/Adobe Photoshop CS#/ Presets/Scripts
# being the CS version
If Photoshop was open close and restart it so that it can pick up the new script.
As part of your action, you can call the script by : File - Scripts - Select the script.


You daman Paul! thanks for your assistance!
by default it is set to open with AE , may want to change it to Ps
Last edited:
He is using an earlier version of Photoshop perhaps. I just have the eye too (I'm on CS3). The paintbrush is image pixels (to lock them). That doesn't have any effect on what the tutorial is doing though.
I wanted to ask about the possibility of copying the name of the selected layer by means of a script. And paste it into any selected layer.
In PS6 this is not possible from the action level.
Or maybe there is a script for that?
Thanks so much!
Last edited:

Paul MR

The Script Master
What you can do is run this script twice, the first time to copy the layer name. You would then have to select the layer(s) to want to rename then run the script again to do the rename(s).
#target photoshop
function main(){
if(!documents.length) return;
if ($.getenv("lName") == null){ 
    var test = getSelectedLayersIdx();
    if(test.length > 1) {
        alert("Only ONE layer should be selected!");
    $.setenv("lName", activeDocument.activeLayer.name);
var selected = getSelectedLayersIdx();
for(var a in selected){
function getSelectedLayersIdx(){ 
      var selectedLayers = new Array(); 
      var backGroundCounter = 1;
            if(activeDocument.artLayers.length > 0){
            backGroundCounter = activeDocument.artLayers[activeDocument.artLayers.length - 1].isBackgroundLayer ? 0 : 1;
      var ref = new ActionReference(); 
      ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("targetLayers"));
      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++){ 
               selectedLayers.push(  desc.getReference( i ).getIndex() +backGroundCounter ); 
      if(app.version.match(/^\d+/) > 15) return selectedLayers ;
         var ref = new ActionReference(); 
         ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" )); 
         ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )) -1);
                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 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 );