Skip to main content
maninthebox390
Participant
October 23, 2015
Question

need script to export all layer names into an excel sheet or text file.

  • October 23, 2015
  • 3 replies
  • 14593 views

are there any scripts to export layer names into an excel sheet or a text file?

This topic has been closed for replies.

3 replies

Participating Frequently
May 29, 2023

Hi. is there a way to skip the Hue/Saturation layers from the list, because they are getting added too?

Thanks,

Mukul

Stephen Marsh
Community Expert
Community Expert
May 29, 2023
quote

Hi. is there a way to skip the Hue/Saturation layers from the list, because they are getting added too?

Thanks,

Mukul


By @chandubhau

 

What method are you using, the one from @jazz-y or another one?

Participating Frequently
May 29, 2023

Yes, the one from @jazz-y .

Stephen Marsh
Community Expert
Community Expert
May 13, 2017

This is also possible with ExifTool using the following command:

exiftool -Photoshop:LayerNames PATH-TO-FILE-or-FOLDER

Which would output the following (which may be a little cryptic, see the screenshot below for a visual):

Color Fill 1, </Layer group>, Layer 0, Layer 1, Layer 2, Layer 3, Group 1, Layer 4, Invert 1

For an Adobe Illustrator .AI file, the command would be:

exiftool -a -XMP-egLayL:LayersName PATH-TO-FILE-or-FOLDER

natrev
Legend
October 23, 2015

Hi maninthebox390,

Try this Code..... and Big Thanks to c.pfaffenbichler.

-yajiv

#target photoshop

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;

        // apply the function to layersets;

          if (theLayer.typename == "ArtLayer") {

          OutFoldCSV("~/Desktop",theLayer.name);

          }

          else {

          allLayers = (collectLayers(theLayer, allLayers))

        // this line includes the layer groups;

          OutFoldCSV("~/Desktop/Layer_Data",theLayer.name);

          }

      };

      //return allLayers

  };

     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");

            }

    }

Inspiring
October 23, 2015

This is a useful working script. I would like to customize the script by adding the file name to the list of layers in the xml file. Can someone provide guidance to achieve this result.

Inspiring
October 23, 2015

Adding the before the first if may work.  Id the document is nor saved it will just add the document mane without any extension

      OutFoldCSV("~/Desktop",app.activeDocument.name);

OutFoldCSV("~/Desktop",app.activeDocument.name);  replaces the layers names in the xls with the document name.

When placed before the first if statement it prints the document name before each layer name in the xls.