CLI MP3 Shuffle Playback

by Robert Daeley

Just in case you're like me and occasionally get on a CLI bender...



Install mpg123 (via Fink or Darwinports).



Let's say you have an existing iTunes-organized music folder at its usual location. Start by getting a list of all of the .mp3 files in that directory and its subdirectories, and saving the list to a file on your Desktop:



find ~/Music/iTunes -name "*.mp3" > ~/Desktop/allmp3s.txt



Next, we feed mpg123 the full list of mp3s as a playlist to randomize:



cat ~/Desktop/allmp3s.txt | mpg123 --shuffle --list -



And that's that. If you'd like a playback time indicator, add a --verbose flag to the mpg123 command. Rock on!


2 Comments

sjk
2006-05-12 22:44:49
There's also play:


% play --help
play audio files from the command line
use: play [-vrl] [-t time] [path]...
-v print status information to stdout
-r play audio files in random order
-l loop playback
-t time play each audio file for at most 'time' seconds
--help display this help message
--version display version information


Example:


% find ~/Music/iTunes -name '*.mp3' | play -rv

Aristotle Pagaltzis
2006-05-14 18:12:28

That cat is unnecessary. Instead just say


mpg123 --shuffle --list ~/Desktop/allmp3s.txt


(Read about that and more unnecessary shell constructs.)