Skip to main content
Known Participant
September 13, 2019
Answered

Copy Layer Name To Clipboard?

  • September 13, 2019
  • 2 replies
  • 5764 views

Hey folks,

 

i am looking for a script, which allows me to copy the name of my active layer to the clipboard.

 

Thank you for your help and best regrads,

 

S.

This topic has been closed for replies.
Correct answer Stephen Marsh

The following code should do the trick, it does exactly what you ask and nothing else:

 

 

 

// Copy Active Layer Name to Clipboard.jsx
#target photoshop 
var doc = activeDocument;
var aLayer = doc.activeLayer.name;
var d = new ActionDescriptor();  
d.putString(stringIDToTypeID("textData"), aLayer);  
executeAction(stringIDToTypeID("textToClipboard"), d, DialogModes.NO); 

 

 

 

Based on:

https://community.adobe.com/t5/Photoshop/Copy-foreground-RGB-values-to-clipboard/td-p/10529244

 

2 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
September 13, 2019

The following code should do the trick, it does exactly what you ask and nothing else:

 

 

 

// Copy Active Layer Name to Clipboard.jsx
#target photoshop 
var doc = activeDocument;
var aLayer = doc.activeLayer.name;
var d = new ActionDescriptor();  
d.putString(stringIDToTypeID("textData"), aLayer);  
executeAction(stringIDToTypeID("textToClipboard"), d, DialogModes.NO); 

 

 

 

Based on:

https://community.adobe.com/t5/Photoshop/Copy-foreground-RGB-values-to-clipboard/td-p/10529244

 

Known Participant
September 14, 2019

This script works awesome...

maybe you can help me out with my next problem. Now i want to rename my current group. The Name should be pasted from the clipboard.

 

thank you very much!

Stephen Marsh
Community Expert
Community Expert
September 14, 2019
I am not sure if this is possible… An alternative may be possible if you can list the exact step by step process.
smithcgl9043167
Inspiring
September 13, 2019
////// Run over matrix layer
var theLayer = activeDocument.activeLayer;
var theParent = theLayer.parent;
if (theParent != activeDocument) {var theString = theParent.name+"-"+theLayer.name}
else {var theString = theLayer.name};

changeLayer(); ////// Choose target layer
function changeLayer(){
	var des = new ActionDescriptor();
	var list = new ActionList();
	var ref = new ActionReference();
	ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Bckw" ));
	des.putReference( charIDToTypeID( "null" ), ref );
	list.putInteger( 3 );
	des.putList( charIDToTypeID( "LyrI" ), list );
	executeAction( charIDToTypeID( "slct" ), des, DialogModes.NO );
}

////////// Paste Name:
app.activeDocument.activeLayer.name = theString;