A few years ago I wrote up a simple bash script to automatically sync my portable music player1 with the music collection on my desktop. Here is the script as of the date of writing. The script's operation is pretty simple. First, an initial rsync is performed using the --dry-run option. I use this mostly as a sanity check to make sure
I'm an avid user of last.fm. Lucky for me, Rockbox has the ability to keep track of all of my listening. I've hopped between a number of programs that are able to scrobble the log file generated by Rockbox. Currently I am using laspyt parse Rockbox's log file and upload my listens to last.fm.
#!/bin/bash
# top level media player path
IPODPATH=""
# media player's music folder
IPODMUSICPATH=""
# music library on computer
LIBRARY=""
echo
echo "Looking for changes..."
echo
rsync --dry-run --progress --update --delete -r $LIBRARY $IPODMUSICPATH
read -p "Proceed with sync? [Y/n] " userIn
userIn=${userIn:-y}
if [ "$userIn" = "n" ]
then
exit 0
else
echo "Syncing Music..."
echo
rsync --progress --update --delete -r $LIBRARY $IPODMUSICPATH
echo
echo "Scrobbling Tracks..."
echo
laspyt.py -b -c -f $IPODPATH/.scrobbler.log
echo
echo "Unmounting..."
echo
udisksctl unmount -b /dev/disk/by-partuuid/[partition-uuid] && udisksctl power-off -b /dev/disk/by-uuid/[disk-uuid]
fi
1. An iPod Video 5.5 with an iFlash-Quad running Rockbox.
2. You can bypass this prompt by piping yes into the script.