Photoshop only offers to export layers/Artboards to files. If you’re using groups (folders) in Photoshop there’s no option available to export those as individual files. This script allows you to export all groups to high-quality .png files.

#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
for(var a=0;a<doc .layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
var saveFile= File(oldPath +"/"+doc.layerSets[a].name +".png");
function dupLayers() { 
    var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm  '), );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb; 
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false; 
pngOpts.transparency = true; 
pngOpts.interlaced = false; 
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts); 

Script By Damien van Holten ( )

Copy the above code into notepad and save it with a .jsx file extension at your desired location. In the Photoshop Menu Bar go to File > Scripts > Browse. Now select the .jsx file in the file browser and Photoshop will now start exporting all your groups to PNG files to the directory the Project file (.psd) is located in.

Checkout this refined version with support for nested layer groups, and ability to export of single layers as well.

You can Further modify the code to export Groups To Files in Photoshop as per your desired formats