title: Photoshop script: output name of every selected top-level layer?
body: <p>I've got an ActionReference Photoshop Javascript code working here that spits out the name of every selected layer:</p>
  <pre><code>var lyrs = [];
  var ref = new ActionReference();
  ref.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
  var targetLayers = executeActionGet(ref).getList(stringIDToTypeID('targetLayers'));
  for (var i = 0; i &lt; targetLayers.count; i++) {
      var ref2 = new ActionReference();
      ref2.putIndex(charIDToTypeID('Lyr '), targetLayers.getReference(i).getIndex() + 1);
      var desc = executeActionGet(ref2);
      lyrs.push(desc.getString(charIDToTypeID('Nm  ')));
  }
  lyrs.join('\\n');
  </code></pre>
  <p>(I join these into a single line-delimited string at the end for use in AppleScript, so ignore that part for now).</p>
  <p>However, this code also includes the nested layers as well (this happens when you shift-click groups of layer sets), and I'm not sure how to modify this code to ignore those lower level nested layers, and only output the list of the top-level layer names.</p>
  <p>I'm very experienced with AppleScript, but I'm a novice at JavaScript, so go easy on me!</p>