In trying to get a list of all music files from a particular album using mdfind I see that the files aren't necessarily returned in any order. I'd prefer album/track order if possible, but can't find a way to provide the sort order on the command line. The current invocation is something like:
mdfind -onlyin "$MUSICROOT" -literal "$MDQUERY"
$MUSICROOT is ~/Music/iTunes $MDQUERY is "kMDItemContentTypeTree == 'public.audio' && kMDItemAlbum == '*$1*'c"
Ideally I'd want to add something like the following to the query:
ORDER BY kMDItemAlbum, kMDItemAudioTrackNumber