Find layergroup of a specific layer in photoshop with javascript

javascript, jsx, layer, photoshop, psd

Solution

If the layer name and the group name are both unique then you can retrieve it simply with:

app.activeDocument.activeLayer = app.activeDocument.layerSets.getByName("my group name").artLayers.getByName("my layer name");

Where "my group name" is the name of the group and "my layer name" is the name of the layer within "my group name".

Problem

Is any way to retrieve the name of a layer group only for the name on a inner layer? I ask this because I'm trying to trim all the content of a folder with a specific layer inside. Can I get any help please?

Original source