Skip to main content
Participating Frequently
July 25, 2021
Answered

Save psd file with the selected layers name script help

  • July 25, 2021
  • 1 reply
  • 1574 views

If I have a photoshop file open with several layers(for example Layer 0, Layer 1, Layer 2 as their layer names) I would like to manually select Layer 2 selected and run the script to take that name and save my file with that name, Layer2.psd

 

Thanks

This topic has been closed for replies.
Correct answer Kukurykus

 

with(activeDocument) saveAs(File('~/desktop/' + activeLayer.name.slice(0, 8)))

 

1 reply

Kukurykus
Brainiac
July 25, 2021
with(activeDocument) saveAs(File(path + '/' + activeLayer.name))
funstrawAuthor
Participating Frequently
July 28, 2021

I have a bunch of images in Bridge and I select a few that I want layered in Photoshop so I choose Tools>Photoshop>Load into Photoshop Layers

So then I wrote this,

function flattenSaveWithLayerName() {
  with(activeDocument) saveAs(File(path + '/' + activeLayer.name))
}
flattenSaveWithLayerName();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

Which I want to save my file into a new file (also into another subfolder, But I'll take what I can get) with a specific layers name(another thing I would prefer the new file to only consist of the first 8 letters/numbers from the layer name, again I'll take what I can get) 

I get dialog "Error 8103: The document has not yet been saved."

 

When I run this script on a a multi-layer file that I create by dragging one file onto another it works. Those layers are Background and Layer 1.  But I need it to work when the layers are placed with their filename.

 

Thanks

Kukurykus
KukurykusCorrect answer
Brainiac
July 28, 2021

 

with(activeDocument) saveAs(File('~/desktop/' + activeLayer.name.slice(0, 8)))