Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

"Export Layers to Files" within a Batched Action doesn't update the "File Name Prefix"

Explorer ,
Mar 25, 2022 Mar 25, 2022

SETUP: Photoshop 23.2.2, MacOS 11.6.4.

 

WHAT I'M UP TO
I'm using "Export Layers to Files," and the File Name Prefix is automatically generated to be the file's name.

BUT!

If I use "Export Layers to Files" as part of a batched Action, the value of the File Name Prefix is baked in to whatever it was at the time of the recorded Action. So, if I'm targeting "Export Layers to Files" for a series of 10 individually named PSD's, the resulting files will all have the same prefix as the first one. Often as the action runs, it will also overwrite the layer files it just created because the file names are identical.

WORK AROUND

I can also use "Render Video" and create a Photoshop Image Sequence, but the document size has a limit of 5,000 pixels, which isn't always ideal

IDEAL BUG FIX

It would be super if the "File Name Prefix" would dynamically update to whatever is the file's name for batched Actions. Also, removing the document size limit for Photoshop Image Sequences within "Render Video" would be great.

SUPER-AMAZING ADDITIONAL OUTCOME
In both "Export Layers to Files," "Render Video" and even "Layer Comps to Files," it would be amazing if these modules could manage a color conversion to sRGB or a user-defined color space.

TOPICS
Actions and scripting
3.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Mentor ,
Mar 25, 2022 Mar 25, 2022

All of these tools have been extremely neglected over the years and i wouldn't expect that they'll ever be touched again. If you need to modify them, you'll need to dig in and re-code what you want/need. 
BUT, the good news is that there's an amazing and free Layers to Files utility that i can't live without:

https://github.com/antipalindrome/Photoshop-Export-Layers-to-Files-Fast

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2022 Mar 25, 2022

@Bruce at TRG 

I don't believe that this is a bug, it is by design, even if the result is not what you want. 

 

Most script parameters are not recorded into actions, as they require special "plug-in script" code to interact with action recording and playback. Although the script parameters can be recorded into an action, I don't believe that this was designed to work with the batch command for the reason that you note (files overwritten with the same name).

 

The script could be edited, however, it is a rather complex script for me to edit (although I have edited it here and here, it's difficult for me to work with such scripts).

 

I tried the script that @Earth Oliver mentioned, and although it has many features, it is obviously not designed for use in the action + batch command. The script interface is called each time and there is no way to use the filename as a prefix without a manual entry (the script could be edited though).

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2022 Mar 25, 2022

@Bruce at TRG 

I believe that the following proof of concept script for a single open, active doc is heading down the right path for your requirements, however, it would require further edits to be more practical.

 

What it does:

  1. Converts to the sRGB ICC profile
  2. Calls the standard "Export Layers to Files" script interface
  3. Steps back in history to delete the sRGB step so that the source document is returned to its previous ICC profile state

 

This uses the default document name as a prefix, so it doesn't overwrite subsequent document saves, which is the problem with recording it into an action and using batch.

 

#target photoshop

app.activeDocument.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, false);

$.evalFile(File(app.path + '/Presets/Scripts/Export Layers To Files.jsx'));

var iddelete = stringIDToTypeID("delete");
var desc1497 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref22 = new ActionReference();
var idhistoryState = stringIDToTypeID("historyState");
var idordinal = stringIDToTypeID("ordinal");
var idlast = stringIDToTypeID("last");
ref22.putEnumerated(idhistoryState, idordinal, idlast);
desc1497.putReference(idnull, ref22);
executeAction(iddelete, desc1497, DialogModes.NO);

 

 

Here is an extended "batch" version that works with all open documents, however, the script interface would be called once per file to set the parameters), so a semi-automated batch. This also uses the default document name as a prefix, so it doesn't overwrite subsequent document saves,

 

#target photoshop

    (function () {

        // CHECK FOR OPEN DOCS
        if (app.documents.length) {

            if (!confirm('After exporting layers, all open docs will be closed without saving! Press "Yes" to continue or "No" to cancel?', true)) {
                // throw alert("Script cancelled!");
                throw null;
            }

            // LOOP OVER OPEN FILES
            while (app.documents.length > 0) {

                app.activeDocument.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, false);

                $.evalFile(File(app.path + '/Presets/Scripts/Export Layers To Files.jsx'));

                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

            }

            // ALERT IF NO DOCS OPEN
        } else {
            alert('You must have at least one document open!');
        }

    }());

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2022 Mar 25, 2022
LATEST

@Bruce at TRG 

Another option that may be better for you is to try the script that I posted in the following topic thread:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-do-i-export-layers-as-png-without...

 

The script either uses save as or export save for web to PNG, however, the file format can be changed fairly easily from PNG to JPEG or another file format. Other options could be added, such as the sRGB ICC conversion, different file naming, save path etc.

 

This script is suitable for recording into an action for use with the batch command if one removes or comments out the end of script alert notification.

 

If this is the better option for you, just let me know what modifications are required, as the original script was intended for a similar but different purpose.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines