Jack
Jack

Reputation: 351

Export (save as) jpg using layer name in Photoshop action

is it possible to copy the current active layer name in Photoshop and use it as the file name for a 'Save As' command in a Photoshop action?

Export Layers to Files isn't suitable because I only want to save a single jpg at a particular point in the action, but because the action is recursive I need a way of changing the filename so that the resulting jpg isn't overwritten with each recursion.

Many thanks!

Upvotes: 2

Views: 4214

Answers (2)

Markus
Markus

Reputation: 141

It's possible to get the name of the activeLayer and save it within an variable:

var layerName = app.activeDocument.activeLayer.name;
var destFile = new File ("~/Desktop/" + layerName + ".jpg");

If you want to document.saveAs() you should set the asCopy parameter to true:

app.activeDocument.saveAs (destFile, docExportOptions, true, Extension.LOWERCASE);

This will prevent a name change of the file you're working with.

Instead of document.saveAs() you could use document.exportDocument() in case you want a really small JPEG output.

app.activeDocument.exportDocument (destFile, ExportType.SAVEFORWEB, docExportOptions);

Upvotes: 2

Carele
Carele

Reputation: 774

Have you tried : "Export layers to files..." in Files, Script ? You don't tell us which method you are using right now. This should export each layer with their name + a custom prefix of your choice.

Also, you may want to take a look at the Insert Menu Item that lets you record a set of actions and then does it automatically. If you need something more complex than the first option, this might be your solution.

Upvotes: 0

Related Questions