collect and export all layer and sub layer names to an excel file
I have an illustrator file with hundreds of layer and sub layers. I need to extract all the layer and sub layer names for referencing by our programmer. I found this photoshop script and am trying to modify it. But it only outputs the top level layer names. The (nested) sub layers don't outputted.
Would be grateful for a tip on how to modify this so that it outputs all layers and sub (nested) layers.
Thanks!
Gary
here's the script:
LayerExcel.jsx
DESCRIPTION
Save layer names to excel file in desktop folder
**********************************************************/
var theLayers = collectLayers(app.activeDocument, []);
////// function collect all layers //////
function collectLayers (theParent, allLayers) {
if (!allLayers) {var allLayers = new Array}
else {};
var theNumber = theParent.layers.length - 1;
for (var m = theNumber; m >= 0;m--) {
var theLayer = theParent.layers
OutFoldCSV("~/Desktop/Layer_Data",theLayer.name);
}
};
function OutFoldCSV(App_Path,Layer_name){
var outfolder = new Folder(App_Path)
if (outfolder.exists == false){
outfolder.create();
var myLogFile = new File(outfolder + "/LayerRef.xls");
myLogFile.open("a", undefined, undefined)
myLogFile.write(Layer_name);
myLogFile.write("\n");
}
else{
var myLogFile = new File(outfolder + "/LayerRef.xls");
myLogFile.open("a", undefined, undefined)
myLogFile.write(Layer_name);
myLogFile.write("\n");
}
}
