A shell script to consolidate your iTunes mp3s into one folder (21 feb 10)
In fact, it's two scripts. The first calls the second.
consolidatemusic.sh :
#!/bin/bash
# If current folder contains iTunes-type music folders, like this:
# ARTIST/ALBUM/some mp3 files
# this will consolodiate them into your home ~/Music folder. Eg.
# Elvis Costello/Armed Forces/Oliver's Army.Mp3 will be copied to
# Elvis-Costello-Armed-Forces-42-Oliver-s-Army.Mp3
# The number is to ensure (or at least make likely) unique file
# names when so many are called things like 'Track 01.mp3'
find . -iname '*mp3' -type f -exec consolidate1mp3.sh "{}" \;
consolidate1mp3.sh :
#!/bin/bash
NAME=`echo $1 | sed 's/ /\\\\\ /g' | sed "s/\'/\\\'/g" | sed 's/[^A-Za-z0-9]/-/g' | sed 's/^--//'`
NAME="$NAME$$.mp3"
cp "$1" $NAME