#!/bin/bash
#
# Quick Rockbox synchronization bash script.
#
# Synchronizes your music collection to your iPod, 
# iAudio or other Rockbox player. Cover images in
# the directory of albums are converted to the 
# appropriate size and format for rockbox.
# Be sure to edit the configuration
#
# Author: Armin Hornung  --  www.arminhornung.de
# Date: 2008-11-04

########################################
# CONFIG OPTIONS

# size of cover images for Rockbox template
# adjust for your template (e.g. 75x75)
coverdim="100x100"

# source (= music collection on HD) and destination
# (= music directory on your Rockbock player).
# ADJUST TO YOUR CONFIGURATION!
# WARNING: Anything in "dest "which is not in "source"
# will be deleted during synchronization!
source="/media/music/"
dest="/media/IPOD/music/"

# END OF CONFIGURATION
########################################

# if you want to exclude certain directories, add another --exclude="..."
rsync -rvth $source $dest --exclude="/lost+found" --exclude="/.Trash*" --delete \
 --modify-window=5 --log-file="sync_rockbox.log"

# create cover files:
cd $dest
find -iname "*.jpg" -o -iname "*.gif" -o -iname "*.png" | while read file
do convert "$file" -thumbnail $coverdim "${file%/*}/cover.bmp"
done
