Original URL: http://www.theregister.co.uk/2010/11/26/itunes_library_howto/

Fanboi primer: How to move your iTunes from PC to Mac

Step-by-step instructions for Jobsian surrender

By Dan Goodin

Posted in Software, 26th November 2010 20:00 GMT

With Steve Jobs's world domination plan proceeding on schedule, I can't be the only iTunes user who wants to transfer my Windows-based music library to a Mac. For all the talk about the ease of switching to OS X, I've been unable to find any Apple-sanctioned way to take my playlists, song ratings, and number of plays with me. And while a variety of downloads promise to do just that, I've found them klugey and unreliable.

With a collection of more than 50,000 songs meticulously rated and sorted into playlists for just about any mood, I wasn't about to start over. So for a long time, I resisted the urge to make the switch. Then I figured out a relatively quick and painless way to make my Mac-based iTunes look and behave just like the iTunes setup I spent years building on my Windows XP machine. It's by no means the only way, but with one minor annoyance (more about that later), it's worked flawlessly for more than a year.

On the Windows XP machine, iTunes looks like this:

Screen capture of iTunes on Win XP

The goal is to make iTunes on the Mac look identical. Here's a tutorial showing how it's done.

It's all relative

The first step is to save the mp3 files to a hard drive that's accessible by the Mac. Because I was using a Mac Book Pro, I copied the entire contents of my old Music folder to an external hard drive. This allows the new system to use the same relative paths as the old one.

The Windows files that store most of the data in the iTunes library are iTunes Library.itl and iTunes Music Library.xml. In Windows XP, they're found on in the My Music\iTunes folder.

Screen capture of iTunes files

Amazingly, there's little difference between these files as they reside on Windows and OS X. Our work involves making a few minor modifications and then copying them to the right Mac folder. The first change we'll make is to the text in iTunes Music Library.xml that shows the file path of each song. On my XP machine, music lives in a folder called Music that's on the M: drive. The file path for the first song in the library is: “file:\\localhost\M:\Music\A.C. Newman\The Slow Wonder\A.C. Newman---The Slow Wonder---01---Miracle Drug.mp3.”

On the Mac, music will live in a folder named Music on the external hard drive. In iTunes, the path of the same A.C. Newman song would be “file://localhost/Volumes/Mac Media Drive/Music/A.C. Newman/The Slow Wonder/A.C. Newman---The Slow Wonder---01---Miracle Drug.mp3” (note the "/" instead of "\").

Screen capture of iTunes XML file

Remember Search and Replace?

To make this happen, all we need to do is a global search and replace, where “file:\\localhost\M:\Music\” is replaced with “file://localhost/Volumes/Mac Media Drive/Music/”. This may be easier said than done, however. My library had more than 1 million lines of text, many of the text editors I used were less than pleased. I ultimately settled on a text editor known as scITE. This is just one of many that will get the job done.

Screen capture of search and replace

Now, it's time to save the converted file to the folder iTunes for Mac uses, but first make sure that iTunes is closed and that you've thoroughly backed up the files in this location in the event you ever want to use its current library. By default, this folder is: “/Users/[account name]/Music/iTunes”.

The XML file will retain precisely the same name as it had on Windows XP, so make sure it's named iTunes Music Library.xml. We will also need to move iTunes Library.itl to the same location, but for some reason, the file is called simply iTunes Library on the Mac. Copy the latter file and paste it to the same location, and then drop the “itl” extension. When you're done “/Users/[account name]/Music/iTunes” will have just two files in it and will look like this:

Screen capture of iTunes files

Feels like the first time

Now, it's time to make sure the external hard drive is connected to the Mac Book Pro and to fire up iTunes. The first time this is done, it usually takes about an hour for iTunes to digest the new library. Just be patient. Eventually, iTunes on you Mac should display your old library, including all your ratings, playlists, listening history and even album art, provided its embedded in the mp3 files themselves.

Screen capture of iTunes on Mac

The only drawback with this hack is an error iTunes delivers shortly after starting up each time. It reads: “We could not complete your iTunes Store Request. An unknown error occurred (4002). There was an error in the iTunes Store. Please try again later.”

Screen capture of iTunes error

A quick Google search shows I'm by no means the only iTunes user to get this error. But so far a fix has been elusive. And that's too bad, since it appears that this error prevents the iTunes Genius feature from working correctly, at least every time I've tried this exercise.

This isn't too big a deal for me, since I've never been too impressed with iTunes Genius. Then again, it's possible Genius has improved and I don't know it because mine is disabled. If you've figured out a way to fix this error, please drop me a line, or leave a comment. ®