2 Replies Latest reply on Feb 28, 2018 6:00 AM by namodayab94056659

    Is there way to get all layer names in current scene using Photoshop scripting?

    namodayab94056659 Level 1

      I have found following code to get all layer names in the current scene using Photoshop scripting.

      var getLayerNames = function() {
          var ref1 = new ActionReference();
          ref1.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
          var count = executeActionGet(ref1).getInteger(charIDToTypeID('NmbL'));
          // get all layer names
          var layerNamesSet = [];
          for (var i = count; i >= 1; i--) {
            var ref2 = new ActionReference();
            ref2.putIndex(charIDToTypeID('Lyr '), i);
            var desc = executeActionGet(ref2);  // Access layer index #i
            var layerSection = typeIDToStringID(desc.getEnumerationValue(stringIDToTypeID('layerSection')));
            if (layerSection == 'layerSectionStart' || layerSection == 'layerSectionEnd') { // Group start and end
            var layerName = desc.getString(stringIDToTypeID("name"));
          return layerNamesSet;


      In above function, list of layers names is returned. But in Photoshop scripting there is a direct way to get layer comps names as in below code.

      var layerComps = app.activeDocument.layerComps;


      I read a lot of references for Photoshop scripting. But I couldn't find direct way to get layer names as layer comps.

      I want to know, is there any way to get layer names in directly?