I found this piece of script offer by a solution on exactly what I try to do here. But I have no idea and can find no related info about this jsx script. I wonder where should I put it or use it in Adobe Photoshop CS6? I tried to use the script with Script->browse and double click on the file named script.jsx where I pasted the code below for export each layer into a file that has SAME background layer applied instead of the default transparent background. However, after I used it, nothing really happened and no error pop up. So I am not sure if anything I have done is not correct.
// variables
var destination = "C:/Users/...../"
var doc = app.activeDocument;
var artlayers = new Array();
// jpeg options
var options = new ExportOptionsSaveForWeb();
options.quality = 80;
options.format = SaveDocumentType.JPEG;
// loop through all layers
var x = 0;
var a = 0;
while (x < doc.layers.length) {
// check if the layer is a item
if (doc.layers[x].kind == LayerKind.NORMAL) {
// add to array
artlayers[a] = x;
a++;
}
x++;
}
var x = 0;
var a = 0;
for (x=0; x < artlayers.length; x++)
{
doc.layers[artlayers[x]].visible = true;
// export as jpeg
try { doc.backgroundLayer.visible = true; } catch (e) {}
file = new File(destination + doc.layers[artlayers[x]].name +".jpg");
doc.exportDocument(file, ExportType.SAVEFORWEB, options);
doc.layers[artlayers[x]].visible = false;
}
Thanks!