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

            }

    }

Participant
February 14, 2021

I have a project I am working on that has almost 1400 layers and I need help with a script that will export the layer names to a text file (preferably) or an .xls file.

I tried the code in this link but it doesn't work... may just need some mods. (It was something I found on the web from 2015).  

Can anyone help me with this?

 

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

 

Thanks in advance!

Scott

Legend
September 6, 2022

SUPERB! I have one question, its possible to exclude not visible layer and skip duplicates? Im working on "translations" system with multiple artboards. Best solution its will be export to CVS only visibile layers and without duplicates so If is already 1 layer named XXX1 so its not shows up in file


#target photoshop
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('json'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
eval('var layersCollection = ' + executeActionGet(r).getString(p).replace(/\\/g, ''));
var needToProcess = collectLayers(layersCollection.layers)
var f = new File('~/Desktop' + '/' + 'layerList.txt');
f.open('w');
f.encoding = 'UTF-8';
for (var a in needToProcess) f.writeln(a)
f.close();
function collectLayers(layersObject, collectedLayers) {
    collectedLayers = collectedLayers ? collectedLayers : [];
    for (var i = 0; i < layersObject.length; i++) {
        var cur = layersObject[i];
        if (cur.visible) {
            if (cur.layers) {
                collectedLayers[cur.name] = true;
                collectLayers(cur.layers, collectedLayers)
            }
            else collectedLayers[cur.name] = true;
        }
    }
    return collectedLayers;
}