Move Layer To The Top

@Pierre_G You’re right, the front enum seems to reference the front of the parent node only, not of the whole layerstack.

The Photoshop DOM approach works fine I guess, but one limitation of it is that you can’t group it together with multiple operations like in batchPlay, to generate only one history state.

The BatchPlay alternative would look like this:

const layerCount = photoshop.action.batchPlay([{
  _obj: 'get',
  _target: [{ _property: 'numberOfLayers' }, { _ref: 'document', _enum: 'ordinal', _value: 'targetEnum' }],
}], { synchronousExecution: true })[0].numberOfLayers

photoshop.action.batchPlay([{
  _obj: 'select',
  _target: { _ref: 'layer', _index: layerCount }
},], {})

However, this is still not a perfect solution since you need to get the layerCount before your batchPlay call (in which you do multiple things). If you add or delete layers during this script, the layerCount won’t be correct anymore, so you’d have to manually count the added / deleted layers.