Skip to main content
Participating Frequently
March 28, 2024
Answered

I want to save as jpg with the same name as the selected layer.

  • March 28, 2024
  • 1 reply
  • 1215 views

Hi all,

 

I want to save as jpg with the same name as the selected layer.

The process is like this. I need to manually select a layer then run a script/action/whatever to save the image file with jpeg quality 12 in the same folder as the PSD file. The name of the file should be the same as the layer name I have manually selected.

 

Thanks in advance!

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

This is working like a charm Stephen! Thank you so much! Where could I add the name of the main file as a prefix? So if the main file with all the layers is called "MainPants.psd" and I run the script then I should get MainPants37.jpg (so without the extension PSD). Thanks again!


I have updated the original code to a new 1.1 version.

 

As per your example, there is no space between the docName and layerName:

 

var jpgSave = new File(docPath + "/" + docName + "" + layerName + ".jpg");

 

I have left a placeholder there to add a space or another separator character if needed, in the example below an _ underscore character:

 

var jpgSave = new File(docPath + "/" + docName + "_" + layerName + ".jpg");

 

1 reply

Stephen Marsh
Community Expert
Community Expert
March 28, 2024

@Dusan331314882hci 

 

I presume that you need to toggle off the visibility of all other layers, so that only the active layer content is saved as a JPEG? Then set the layer visibility back to how it was beforehand...

Participating Frequently
March 28, 2024

I need to turn on the visibility of that layer, save the file with the name of that selected layer.

Then turn manually some layers off and some other layers on. Then select again a layer to get the file name for the save and so on.

mglush
Community Expert
Community Expert
March 28, 2024

Hi!

If you use the Export>Layers to files feature under the File menu, you can do just that.

1. Name the layer whatever name you like.

2. Make sure the layer visibility is turned on.

3. Choose File>Export>Layers to files and in the dialog box choose where you want to save them images, choose your general file name and the quality of hte jpg.

4. Click Run. It will automatically save your file with the Layer name in addition to the general name you give it.

Let us know if that helps!

Michelle