ITunes Scripts

From Stack Overflow
Jump to: navigation, search

compareLibrary.sh

#!/bin/sh
LIBRARY=~/Music/iTunes/iTunes\ Music\ Library.xml
PREFIX=~/Music/iTunes/iTunes\ Music/
grep file: "$LIBRARY" \
 | sed 's/^.*file:\/\/localhost//' \
 | sed 's/\<.*$//' \
 | sed 's/%20/ /g' \
 | sed 's/%23/#/g' \
 | sed 's/%5B/[/g' \
 | sed 's/%5D/]/g' \
 | sed 's/&/\&/g' \
 | sed "s|$PREFIX||g" \
 | sort \
 > list_library1.txt
find "$PREFIX" -type f \
 | grep -v cover.jpg \
 | grep -v DS_Store \
 | sed "s|$PREFIX/||g" \
 | perl -pne 's/([\x80-\xFF])/uc sprintf("%%%02x",ord($1))/seg' \
 | sort \
 > list_real.txt
cat list_library1.txt \
 | sed 's/&/\&/g' \
 > list_library.txt
diff list_real.txt list_library.txt > list_diff.txt

extractLibrary.sh

#!/bin/sh
grep file: new.xml \
 | sed 's/^.*file:\/\/localhost//' \
 | sed 's/\<.*$//' \
 | sed 's/%20/ /g' \
 | sort \
 > list.txt
Personal tools