Skip to main content
Participant
August 21, 2013
Question

Batch Rename PSD Layers to File Name Script?

  • August 21, 2013
  • 2 replies
  • 4043 views

Hello,

I just recieved several thousand .PSD files for a job containing a single layer (named "Layer 1") on a transparent background. I'm trying to find a way to batch rename the layer in each of these files as the file name, sans the file extension. Is there a script out there that can do this for me? Forgive me, I am not too hip with scripts.

Windows 7 PC, CS6

Thank you!

This topic has been closed for replies.

2 replies

Jim Mooney
Participating Frequently
August 29, 2016

I got this to work using the ExtendScript Toolkit.  But how can this be reversed so that the document name

gets renamed whatever the active layer name is?  I tried a few different rearrangements but couldn't get it to work.

Thanks!

JJMack
Community Expert
Community Expert
August 29, 2016

You can not rename and open document that was opened from a file.  You Can save the current open document as a new file, Sometimes Photoshop will switch the current document to that new document.   You could also script so it would do that for you script. For you could save the new file, Close the current open document no save and open the new file. Optionally you could delete the old file by removing it from your file system.   Photoshop DOM Document Object Name is a Read Only item A script can not change ActiveDocument.name.....

JJMack
Jim Mooney
Participating Frequently
August 29, 2016

Ah OK, thanks.

Inspiring
August 21, 2013

Save the line below into a plain text file and give it the .jsx extension.

app.activeDocument.activeLayer.name = decodeURI(app.activeDocument.name).match(/(.*)(\.[^\.]+)/)[1];

Then create an action that runs that script. Then run File-Automate-Batch using that action.

Participant
August 21, 2013

Thank you, I'll give this a try!