Firstly, thanks for the fast responses!
To clarify my question - the getSelectedLayersIdx() above gives a list of integers that appear to be some kind of internal ID and are not necessarily sequential (at least in my tests). Whereas the list(array?) returned by doc.layers is of course just sequentially indexed.
So I was looking for a way to translate between the two - no idea if its actually possible or a sensible approach?
To answer your questions - after I have the layer I copy it to a new temp document and do a few ops like cropping etc. before saving/exporting it.
pfaffenbichler- thanks for the selectLayerByIndex() - I can use this to select the layer I want then copy it - and complete my script. Is there a way to copy a layer without having to select it? (I have some very large docs that will be slowed down by this)
Thanks again for the replies - I am not very familiar with the "macro-style" photoshop commands - any pointers on reference for this would be gratefully received.