Sunday, September 27, 2009

remove duplicates from iTunes Music folder

Use fdupes

In the terminal:

sudo port install fdupes

cd ~/Music/iTunes/iTunes Music

fdupes -rf Music/ | tee duplicates.txt

(-r flag recursively reads subdirectories, -f omits the first match, tee redirects the output to a file)

#parse the duplicates file

sort duplicates.txt | uniq | grep -v '^$'

#remove the duplicates
while read line; do rm -v '$line'; done < duplicates.txt

#clean up
rm duplicates.txt

itunes will have broken links to the deleted files:

Within itunes I remove all files from my library choosing the "keep files" option, and drag the Music folder back into iTunes

No comments:

Post a Comment