Skip to main content
Inspiring
October 30, 2020
Answered

Save for web jpg , file name the active layer name

  • October 30, 2020
  • 2 replies
  • 2527 views

Hello!

I am looking for a script or action.

At default Photoshop "save for web panel" I need the file name to be the selected layer name.

Thanks!

This topic has been closed for replies.
Correct answer siomosp

Thank you, Conrad, for your reply

Your suggestion is not fits my needs  unfortunately.

This is my final  solution,  a beginner code,  but it works

// Save for web, jpg
// file name =  layer parent group name 
#target photoshop
var outputFolder = Folder.selectDialog("Choose a folder to save your  file.");
var theLayer = activeDocument.activeLayer;
var theName = theLayer.parent.name;
var doc = app.activeDocument;
var activeLayer = doc.activeLayer;
var newName = theName+'.jpg';
//jpg options
var jpgoptions = new ExportOptionsSaveForWeb();
jpgoptions.interlaced = false;
jpgoptions.quality = 50;
jpgoptions.includeProfile = false;
jpgoptions.format = SaveDocumentType.JPEG; // Document Type
doc.exportDocument(File(doc.path+'/'+newName),ExportType.SAVEFORWEB,jpgoptions);

 

 

2 replies

Conrad_C
Community Expert
Community Expert
October 30, 2020

The layer name will be the file name if you choose Layer > Export As.

If you selected multiple layers, each would be listed individually for export as separate files, and each file name would be the name of each layer.

 

 

The other export commands, such as File > Export > Export As or File > Export > Save for Web (Legacy), export all layers merged. That’s why they are under the File menu.

 

You will also find the Export As command on the Layers panel menu. Of course that’s the layer-based Export As command, not the file-based one.

siomospAuthorCorrect answer
Inspiring
October 30, 2020

Thank you, Conrad, for your reply

Your suggestion is not fits my needs  unfortunately.

This is my final  solution,  a beginner code,  but it works

// Save for web, jpg
// file name =  layer parent group name 
#target photoshop
var outputFolder = Folder.selectDialog("Choose a folder to save your  file.");
var theLayer = activeDocument.activeLayer;
var theName = theLayer.parent.name;
var doc = app.activeDocument;
var activeLayer = doc.activeLayer;
var newName = theName+'.jpg';
//jpg options
var jpgoptions = new ExportOptionsSaveForWeb();
jpgoptions.interlaced = false;
jpgoptions.quality = 50;
jpgoptions.includeProfile = false;
jpgoptions.format = SaveDocumentType.JPEG; // Document Type
doc.exportDocument(File(doc.path+'/'+newName),ExportType.SAVEFORWEB,jpgoptions);

 

 

Participating Frequently
June 23, 2021

Hi Siomosp, I also wanted to do the exact same thing. But I'm not familiar with scrips. Could you please tell me

how and where to apply this script?

 

Thank you.

Darshana

marliton
Community Expert
Community Expert
October 30, 2020

Hi. Maybe this Photoshop function can be helpful: Generate image assets from layers

 

Marlon Ceballos
siomospAuthor
Inspiring
October 30, 2020

Hi Marlon,

unfortunately not,

but thanks!