Play all the music in a folder, on shuffle

mplayer -shuffle *
Page up for next song

By: ProfOak
2010-04-16 20:53:40

1 Alternatives + Submit Alt

  • Play files in shuffle mode with bash and mpg123. Why bother using big-as-hell stuff like mplayer? This will play all your music files contained in */* (in my case author/song.format) with bash and mplayer showing a nice output. Show Sample Output

    while [[ 1 ]]; do n=( */* ); s=${n[$(($RANDOM%${#n[@]}))]}; echo -e " - $s"; mpg123 -q "$s"; done
    XayOn · 2013-01-18 09:20:58 0

What Others Think

Wow, I didn't know that MPlayer can do something like that! Thank you! By the way, on my system (Debian Lenny, MPlayer dev-SVN-r26940) PageDown don't switch back to previous song ? it just rewinds current one to the beginning.
Minoru · 606 weeks and 2 days ago
To include files in subdirs too you can do: mplayer -shuffle -playlist Pressing < to go to the previous track only seems to work if you're not using shuffle.
rkulla · 606 weeks and 2 days ago
I meant: mplayer -shuffle -playlist
rkulla · 606 weeks and 2 days ago
Hmm it's not interpreting my text right. I wish this site would let you delete comments. I'll try again: mplayer -shuffle -playlist <(find "$PWD")
rkulla · 606 weeks and 2 days ago
for the -playlist switch, you have to make a file that contains the songs. Either copy+paste the titles or type `ls Song_na* >` or whatever you want your playlist file to be.
ProfOak · 605 weeks ago
Nice! Thanks!
TheShadowFog · 524 weeks and 6 days ago
Submitted an alternative =) while [[ 1 ]]; do n=( */* ); s=${n[$(($RANDOM%${#n[@]}))]}; echo -e " - $s"; mpg123 -q "$s"; done Quite longer and uglier, but just mpg123 and bash, a nice, clean output and much less memory usage.
XayOn · 462 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: