Profile photo of the authorJames Tiplady: Hyperlinks, Etc.

Merging Two iTunes Libraries

20th October 2010, a Wednesday

This post is over 13 years old. Beware of stale technical details.

I recently had the somewhat unenviable task of combining two large iTunes libraries into one and found that there's pretty much no information on this online, so I thought I'd share my "technique" in the hope that someone might find it useful. Various guides detail the steps required to move a library to another machine, but not to merge it with another - the process shares some actions, but isn't quite the same. So here you are, lucky you.

My situation was thus: I had an older Windows PC with a large-ish (40GB) library from an old version of iTunes (I forget which, probably 7), synced with my iPod Classic. I also had my MacBook Pro (iTunes 10) with a smaller library (15GB) synced to my iPhone. I wanted to merge the two in such a way that all the meta-data (play counts, ratings, playlists etc) would be preserved - combined into one definitive library on my MacBook that I could sync to both iPod and iPhone.

I didn't have constant access to the old PC - only a copy of my iTunes library and music files on a USB disk. This meant a couple of extra steps which I'll detail below. You'll need a bit of patience and some spare disk space to do this properly - also note that I did most of this on a Mac, so if you're on Windows your mileage may vary slightly. Please back up any files before making changes! It's easy and good for your health.

One key prerequisite is that both old and new libraries must be sorted by iTunes - you need to use the "keep my music library organised" option so that iTunes organises your files by artist and album. If you don't do this, you'll have a tricky time merging the two folder trees together (unless they both use the same custom sorting scheme, but you'll be lucky).

1. Due to the difference in iTunes library versions, the first thing I did was update the older library to the latest schema. I'm not sure if there are actually any significant differences between 7 and 10, but I didn't want to make things any harder than necessary. I updated the older library by firing up a Windows 7 virtual machine (I use VirtualBox, which is awesome - but you could just as well use any other Mac or PC separate from your main machine), installing iTunes 10 and replacing the default library with a copy of my old library files. Restarting iTunes automatically updated them, and my old library was shown in iTunes (though none of the tracks were playable because the files weren't on the system - no problem).

2. I went through a period a while back where I was adding new music to both libraries, so in order to minimise duplicates I sorted my newly updated "older" library by "date added" and deleted everything added after the point where my "newer" library started. I didn't lose any play counts or ratings here because at this point I was only listening to music on my Mac. I also deleted all podcasts from my older library (had them set up on the new library anyway).

3. I then exported the "older" library from iTunes: File > Library > Export Library. This creates an XML file containing all the library data - I named this something like "Old Library Export" and moved it into OS X via the USB disk.

4. Back on my Mac, where the final merged library was to reside, I set about copying my old music files from the USB disk into my existing ("newer") library. Both libraries used the following folder structure: iTunes > iTunes Music > [Artist] > [Album]. This meant that I could easily copy the old media into the new library's folder structure. I essentially did this by opening the "iTunes Music" folder on my Mac ("newer" library), the "iTunes Music" folder on the USB disk ("older" library, copied from my PC) and dragging (moving) the contents of the older library folder into the newer library folder. Because my older library contained much more music, most of the artists would be new additions and wouldn't already exist in the newer library. Important Mac-specific note: If Finder asks you if you want to replace folders, say no to all. On OS X, if two folders have the same name, the original will be replaced completely, irrespective of any common contents. This is a key difference from Windows, where the contents of the folders will be merged. OS X doesn't do that, and it's something you need to be aware of.

5. Most of the artists moved across fine - I was left with a handful of artists remaining in the "older" folder that existed in both libraries, and I needed to merge them manually by copying the albums themselves across, overwriting or deleting where necessary. This is basically common sense so hopefully you'll be able to work this part out.

6. At this point all my actual music files were merged. Before I could merge the library data itself I needed to make some changes to the XML export of the older library (from earlier), because it contained references to paths on my old system that wouldn't make any sense on my Mac. I opened the XML file in TextMate (you could use any reasonable text editor) and did a find-and-replace, searching for file://localhost/C:/Users/James/ Music/iTunes/iTunes%20Media/ and replacing it with file://localhost/Users/james/ Music/iTunes/iTunes%20Music/ (split over two lines here for readability). This updated all the Windows-specific paths to the correct paths on my Mac. You'll need to adjust those paths to reflect your username(s) and the location of your media files.

7. The final step was to merge the library data files.I took a backup of my Mac iTunes library file, then used File > Library > Import Playlist, selecting the XML file created earlier. After much processing and thrashing around, iTunes eventually presented me with a shiny new Library view showing the merged contents of both my old and new libraries. Woo!

Cleanup that I had to perform myself at this point included a few duplicate artists, genres that had become numbers instead of names, and album artwork. iTunes doesn't preserve album art unless you copy it across yourself (I'm sure this is straightforward enough but I didn't do it), so the easiest thing is to just hit Advanced > Get Album Artwork and let it sift through your collection itself and download as necessary. Then it was just a matter of syncing my devices and hurrah! Access to all my tunes once again.