Skip to main content
ofirbenami1980
Participant
March 12, 2017
Question

Export layers to files stopped working after last update

  • March 12, 2017
  • 11 replies
  • 5377 views

Export layers to files stopped working after last update. opening a dialogue: The command "Delete" is not currently available.
This script is crucial for my work flow. Any suggestions?

 

I've tried using the "new" export as.. and quick export, but these currently cannot be recorded in the actions panel.

11 replies

Participant
March 11, 2025

Don't know if anyone figured it out.

In my case it was grouped layers, which caused an issue, but ChatGPT made it possible to fix. 

Here's a JSX code to run a script file which solves a porblem. It works with grouped layers within .psd file. 

#target photoshop

function exportLayersAsPNG() {
    if (!app.documents.length) {
        alert("Brak otwartego dokumentu!");
        return;
    }

    var doc = app.activeDocument;
    var folder = Folder.selectDialog("Wybierz folder do zapisu PNG");

    if (!folder) {
        alert("Nie wybrano folderu. Anulowano eksport.");
        return;
    }

    var exportOptions = new ExportOptionsSaveForWeb();
    exportOptions.format = SaveDocumentType.PNG;
    exportOptions.PNG8 = false; // PNG-24
    exportOptions.transparency = true;
    exportOptions.interlaced = false;
    exportOptions.quality = 100;

    // Zapamiętanie stanu widoczności warstw
    var layerStates = {};
    saveLayerVisibility(doc.layers, layerStates);

    // Przetwarzanie warstw, również w grupach
    processLayers(doc.layers, folder, exportOptions, "");

    // Przywrócenie pierwotnej widoczności warstw
    restoreLayerVisibility(doc.layers, layerStates);

    alert("Eksport zakończony!");
}

// Rekursywne przeszukiwanie wszystkich warstw, również wewnątrz grup
function processLayers(layerSet, folder, exportOptions, parentName) {
    if (parentName == undefined) parentName = ""; // Poprawka dla ExtendScript

    for (var i = 0; i < layerSet.length; i++) {
        var layer = layerSet[i];
        var layerName = parentName ? parentName + "_" + layer.name : layer.name;
        layerName = layerName.replace(/[\/\\:*?"<>|]/g, "_"); // Usunięcie niedozwolonych znaków

        if (layer.typename === "LayerSet") {
            // Jeśli to grupa warstw, przeszukujemy jej zawartość
            processLayers(layer.layers, folder, exportOptions, layerName);
        } else if (layer.typename === "ArtLayer") {
            exportLayerAsPNG(layer, folder, exportOptions, layerName);
        }
    }
}

// Eksport pojedynczej warstwy jako PNG
function exportLayerAsPNG(layer, folder, exportOptions, layerName) {
    var doc = app.activeDocument;

    // Ukrycie wszystkich warstw
    hideAllLayers(doc.layers);

    // Ustawienie wyłącznie eksportowanej warstwy jako widocznej
    layer.visible = true;

    // Eksportowanie warstwy do pliku PNG
    var file = new File(folder + "/" + layerName + ".png");
    doc.exportDocument(file, ExportType.SAVEFORWEB, exportOptions);
}

// Ukrywa wszystkie warstwy w dokumencie
function hideAllLayers(layerSet) {
    for (var i = 0; i < layerSet.length; i++) {
        var layer = layerSet[i];
        if (layer.typename === "LayerSet") {
            hideAllLayers(layer.layers);
        } else {
            layer.visible = false;
        }
    }
}

// Zapisuje oryginalny stan widoczności warstw
function saveLayerVisibility(layerSet, state) {
    for (var i = 0; i < layerSet.length; i++) {
        var layer = layerSet[i];
        state[layer.name] = layer.visible;
        if (layer.typename === "LayerSet") {
            saveLayerVisibility(layer.layers, state);
        }
    }
}

// Przywraca stan widoczności warstw
function restoreLayerVisibility(layerSet, state) {
    for (var i = 0; i < layerSet.length; i++) {
        var layer = layerSet[i];
        if (state.hasOwnProperty(layer.name)) {
            layer.visible = state[layer.name];
        }
        if (layer.typename === "LayerSet") {
            restoreLayerVisibility(layer.layers, state);
        }
    }
}

// Uruchomienie skryptu
exportLayersAsPNG();

 

Participant
September 27, 2023

SOLVED: This has irritated me for a while, but it looks like there's a new way to do it. I'm on a Mac using OS Ventura 13. 

You go to you layers panel in your psd, select all the layers you want to export and right click on them in the layers panel, then select "Export as". it will open a dialogue box that allows you to choose the extension and size and a few other things and then you export. thers a bit of a lag while using the dialogue box but when you hit export it does all the layers at once.

hope that helps somene else.


revolution52
Participant
February 1, 2022

Hi, if you are getting this error, check that the layers you are trying to export are not inside a Group. The script will fail when it tries to delete the Group Folder. To avoid this, keep your layers at the top level (without grouping) and that will solve the issue. 

Participant
October 27, 2021

I've also been having this issue on Mac. I found that a layer with a 'Colour Overlay' was cuasing the issue even though it want visible. Maybe try 'Rasterise Layer Style' on any layers with a colour overlay and see if it helps for you!

Tom Ruark
Inspiring
September 21, 2021

Does this fail on all document types or only with certain artboards and layer nesting? Do you have "Visible Layers Only" checked or unchecked? Does it matter if you try unchecked or checked? Only with artboards?

 

If you could upload a sample image that fails.

Known Participant
October 22, 2021

I found that it works with .jpg, but not with PNG...it may also be that visible groups with no visible layers may trigger the fail as well. I haven't tested that extensively, but when I switched from png (failed) to jpg, it worked.

ngp26160161
Participant
October 25, 2021

same problem here... no clue

Glevity
Known Participant
July 19, 2021

I'm having the same issue but don't see any solutions preseneted from Adobe. I am on CC2021. Has anyone found a solution?

Participant
September 21, 2021

this is still broken... what am I paying for

 

Participant
September 30, 2020

Encountering this issue in 2020. 'Export layers to files' is stripping the layers, opening a dialogue: The command "Delete" is not currently available, and won't export jpegs to artboard size, but instead adds blank space around the board. Did anyone have luck with this? 

Participating Frequently
April 24, 2020

I am using 21.1.1 version of Photoshop on Mac 10.15.4 Sierra. It doesn't work at all. I have no groups, but probably smart objects? Who doesn't use smart objects? I am trying to export layers to png and I also tried exporting to .psd.

Participating Frequently
October 3, 2019

Not using the feature much, but encountering exactly this issue in 2019. At least for me the script worked when my document was flat (lots of boring frames for a technical test...), but encountered the Delete Unavailable issue as it was stripping down the non-target layers and encountered a layer group.  Not sure if the way Photoshop handles deletion of groups changed since the script was written, but pulling all grouped layers out to the top level, deleting the groups, and re-running the export seems to work.  Awkward, certainly, but probably far faster than other manual aternatives involving selecting/showing layers one at a time for comping or manual saves.

Known Participant
November 23, 2017

I rely on this export layers to files function for making catalogues (I don't want the exported elements to be cropped but to remain in position on the canvas size).

The export failed on two different Macs running CC 2018, and failed on a third Mac running CC 2017.

I finally got the export layers to files to work on a fourth Mac running CC 2015.

I wish Adobe would stop breaking really useful bits of Photoshop.

Regards, Peter