Not impossible; the information IS available, but it is a multi-part process. Your script has to do the work of the GUI interface, which means you have to call the CLI to get the information to know what is on the disk, parse it to find which tracks you CAN chose, apply your rules to it, and then call the CLI with a command line to fetch the tracks you want.
Complicating it is that they CLI is not documented to the level necessary to do this without a lot of manual work, locating the "hidden command switches", and testing them to verify how they work. I haven't bothered to go to that point, but others have.
is one such effort, and it might provide some insight to your question.