Select layer inside a group inside artboard

Hi. I am trying to select specific layer inside an artboard but when the layer is inside a group i can’t select it.

  for(layer of app.activeDocument.artboards[0].children){
if ( == name) {
    layer.selected = true

I think i could somehow extract children from the group, from like app.activeDocument.artboards[0].children[0].children
but I don’t know how to implement to work properly.

Indeed, with your approach you’d have to check for the layers type and if it’s a group, iterate its children to find the layer.

However, in regards to performance that’s not really a great solution. Unfortunately the DOM API currently doesn’t provide much functionality for selecting layers.

Via BatchPlay, it’s super easy to select a layer by name, here’s the descriptor:

    _obj: 'select',
    _target: { _ref: 'layer', _name:*name* },