Skip to main content
Known Participant
February 28, 2019
Answered

PS Script to find specific text in layer names

  • February 28, 2019
  • 1 reply
  • 1694 views

Hello,

I have this script to change a layer name according to a document name. However, the script will also add extension ".psd" to the layer name.

e.g.: Document name is orange.psd and after the script is launched the name of the selected layer will change from Layer 1 to orange.psd.

But I dont want the ."psd" suffix. It would be great to import something like find ".psd" and replace it with nothing 🙂

Thanks

#target photoshop

activeDocument.activeLayer.name=activeDocument.name;

This topic has been closed for replies.
Correct answer SuperMerlin

#target photoshop 

activeDocument.activeLayer.name=decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');

1 reply

SuperMerlin
SuperMerlinCorrect answer
Inspiring
February 28, 2019

#target photoshop 

activeDocument.activeLayer.name=decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');

Participating Frequently
March 15, 2023

is it possible to add the document name to the layer name rather than replacing it? I need to add the document name before the layer name, and then run appy to all layers

Stephen Marsh
Community Expert
Community Expert
March 15, 2023

Amazing! Thanks!!!!


You're welcome!