Script to Export Contents of all Smart Objects in a Photoshop file
I am trying to write a script that will batch export all smart objects as files.
Like using the menu -> Layer/SmartObjects/Export Contents... but does it for every Smart Object is the photoshop file.
I have written some code that searches all layers and can determine if it is a Smart Object, but I am stuck on how to export the smart objects content as a file.
var oldPath = activeDocument.path;
function ExportSmartObject(layerNode) {
for (var i=0; i<layerNode.length; i++) {
ExportSmartObject(layerNode[i].layerSets);
for(var layerIndex=0; layerIndex < layerNode[i].artLayers.length; layerIndex++) {
var layer=layerNode[i].artLayers[layerIndex];
if (layer.kind == "LayerKind.SMARTOBJECT") {
alert("Smart Object Found")
// Export Smart Object Content
}
}
}
}
ExportSmartObject(app.activeDocument.layerSets);
