Wikia

Music Player Daemon Community Wiki

Hack:mpdshuf

Talk0
517pages on
this wiki

Small shellhack that will move songs around on your playlist. This was written in a few minutes and I'm not a bash guru, so bear with me.

I release this in an almost-PD license: copy it, edit it, change it, but please give credit, that's pretty much all I ask.

Code
#!/bin/bash

# mpcshuf.sh: "Shuffles" the mpd playlist.
# By Renan Birck, '09. 
# Last updated: 02/04/09.

UPPER=`mpc | sed '2q;d' | cut -f 2 -d ' ' | cut -f 2 -d '/'` # How many times max. to shuffle?

for X in `seq 0 $UPPER`; do
MAXSONG=$UPPER;
RANFROM=$RANDOM;
RANTO=$RANDOM;


let "RANFROM = $RANFROM % $MAXSONG + 1";
let "RANTO = $RANTO % $MAXSONG + 1";


mpc move $RANFROM $RANTO;
echo "Moved song " $RANFROM " to " $RANTO; # For debugging, remove if you want.
done

Author
renan.dream AT gmail.com

Around Wikia's network

Random Wiki