Thu May 22 2008
This is a simple but convenient Ruby script for anyone who has gotten duplicate
tracks into their iTunes Library and wants to remove them.
iTunes currently provides some
safeguards that prevent the importation
of duplicate tracks, but nonetheless lots of people in one way or another
wind up with them.
Thus there are lots of Applescripts and other hacks out there for removing
duplicate iTunes tracks. But I wanted a simple, precise command-line program
that could take care of the problem for me. By “precise” I mean a program
that defines “duplicate” as an exact duplicate, meaning that the underlying
media files have the same MD5 digest signature.
Other duplicate-removal programs, as well as Apple’s own iTunes “Show
Duplicates” menu command, can be pretty lax in how they define “duplicates.”
For example, I have two copies of “Speed of Sound” by Coldplay. One is a
high-quality, non-DRMed 8.9MB m4a file. The other is lower-quality, DRMed
4.5MB m4p file. The “Show Duplicates” menu command on iTunes thinks they are
duplicates. But clearly, they are not.
The best dup-removal program out there looks like
Dupin from Doug’s
AppleScripts for iTunes. But it’s not free. It costs $15.
So for people who want a free program that finds and removes exact duplicates
from iTunes, I created itunes-rm-dups (a.k.a. iTunes Duplicate Track
Remover).
OS X Leopard
itunes-rm-dups packaged as a Ruby Gem and distributed from RubyForge. So
installation is very simple. Open a Terminal, and type the following:
sudo gem install itunes-rm-dups
You may be prompted to enter your administrator’s password.
To run itunes-rm-dups, simply type
itunes-rm-dups
You can also limit the scope of the track-search to a particular artist or
album title. For example you can type
itumes-rm-dups --artist 'david bowie'
to find and remove duplicate tracks by the artist David Bowie only.
You can also type
itunes-rm-dups --album 'best of bowie'
to find and remove duplicate tracks from that album only.
When you run itunes-rm-dups, you will see output as the program works through
the tracks in your iTunes library. You’ll be prompted to answer a question or
two. Before it does anything destructive, the program will show you the
duplicates it has detected and which ones it thinks you want to keep and
which it intends to remove from the library and delete from your file system.
At this point you can confirm the program’s analysis and let it proceed with
duplicate-removal, or you can abort.
This software will be periodically updated with bugfixes and other improvements.
To get the latest version after the initial installation, just type
sudo gem update itunes-rm-dups
to update your copy of itunes-rm-dups to the latest version.
Here’s sample output from the program in action. I edited it
down to keep it short.
To leave any feedback, please visit the RubyForge
page for this project. You can
file bug reports, request enhancements and features, and comment in a
discussion forum.
This project is open source. You can browse the source
here.
a tweaked version of the micro theme by seaofclouds, and powered by YAML, Textile, and this simple, home-grown ruby build script.