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(/\.[^\.]+$/, '');

ParanoicAuthor
Known Participant
February 28, 2019

Perfect!