Always selected file

Hello.

How to make last uploaded file "always selected" or marked and ready for printing?

I have 3 hw buttons to START, STOP, and PAUSE.

After powerOff Printer (over PSU Plugin) or start, or reConnect to printer no file is marked for print.

Is there any way (API, python script etc.), for doing this without PC or mobile phone and manualy click?

There is AutoselectPlugi, but it olny works when new file was uploaded (1x time).

Thanks for answer.

Another question formulation: How to select last uploaded file by script? After disconnect and reconnect printer or restart cycle.

OK, like always, answered by myself :slight_smile:

#!/bin/sh
UPLOADPATH=/home/octoprint/.octoprint/uploads
LASTFILENAME=$(ls -Art $UPLOADPATH/*.gcode | tail -n 1)
LASTFILENAME=$(basename -- "$LASTFILENAME")
curl -k4 --request POST -H 'X-Api-Key: XXXXXXXXXXXXXXXXXXXXXXXXX' -H 'Content-Type: application/json' --data '{"command":"select","print":false}' http://localhost:5000/api/files/local/$LASTFILENAME