Crap mp3 players

So Aldi have 2gb iPod shuffle knockoffs for $10. Grand, richo thinks and off he sets.

I got home with my players, and discovered that they have no random function, and get angry. Luckily, I’m an uberdork and hacked up 2 shell scripts to save the day:

mvmusic :
#!/bin/sh
APP=$0

usage()
{
echo "$APP"
exit 1
}

source=$1;
if [ "$source" = "" ]; then
usage
fi
shift

target=$1
if [ "$target" = "" ]; then
usage
fi
shift

echo -n "${target}: "
rm -rI $target/*

find $source -name \*.mp3 -exec _mv_mp3 {} $target \;

_mv_mp3

#!/bin/sh
usage()
{
echo "usage: know what you're doing"
exit 1
}

gen_path()
{
str=$( tmpath=$1/$str
while [ -e $tmpath ]; do
str=$( tmpath=$1/$str
echo $tmpath
done
echo $tmpath
}

if [ "$1" = "" ]; then
usage
fi

if [ "$2" = "" ]; then
usage
fi

to=`gen_path $2`
mv "$1" $to

Together, they hose the contents of my music player and copy the contents of a directory to the player, with random filenames (pseudorandom play order)

I've got a few todo items relating to it, namely the ability to randomly select tracks until the media player fills and probably a bit more cleverness relating to the initial cleaning of the player, but on the whole I'm pretty happy with it. It gets the job done.

About richo

I enjoy exploring interesting concepts in weird languages. I also like hacking on all of the things.
This entry was posted in Guides and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>