How to Migrate iTunes from Windows to the Mac

I recently switched from Windows to the Mac at home, and was unable to find a comprehensive guide to migrating iTunes from Windows to the Mac. This post attempts to help fill that gap.

To follow this guide you should be comfortable using the Windows and Mac operating systems and a text editor. I recommend reading all the way through the instructions before beginning.

1. Run iTunes

First, run iTunes on the Mac. This should create a default iTunes folder structure in your home directory, at ~/Music/iTunes. When you first run iTunes it may ask if you want to scan your hard drive for music; do not allow iTunes to do this. It may also ask if you want iTunes to keep your music organized for you. Make sure you select the setting that matches your Windows iTunes configuration; you may need to edit the iTunes Advanced preferences to do so.

Now that you’ve gotten the initial iTunes configuration set up, quit iTunes before proceeding.

2. Copy Music Files

Next you need to copy your music files from Windows to the Mac. I recommend that you use an external hard drive to do this. Do not use a network connection to copy the files; as of this writing there is a bug in the Mac Samba implementation that causes some remote Windows directories to appear empty when they are not.

You may have configured your Windows installation of iTunes so that it didn’t organize your files for you. This is usually the case if you were using another system to organize your MP3 files prior to adopting iTunes. In that case, you may have an extra folder (for example, D:\MP3) on your Windows machine that contains much of your music. You’ll want to copy that folder to your Mac home directory; I recommend ~/Music/MP3.

Whether or not you let iTunes organize your music on Windows, iTunes always organizes your purchased music for you. Therefore you will need to copy your Windows folder My Documents\My Music\iTunes Music\ to your Mac as ~/Music/iTunes/iTunes Music.

3. Copy and edit iTunes Music Library.xml

Fortunately for us the Apple engineers used XML for the iTunes database. This means that the same file format works on both Windows and the Mac, and we can edit the file to tell iTunes about the new file locations.

Before you copy the file iTunes Music Library.xml to your Mac, I recommend that you make a backup copy of that file in case you discover later that you didn’t mean to overwrite it.

Using your favorite Mac text editor (such as TextEdit, BBEdit, or Emacs), edit the file iTunes Music Library.xml. Search and replace all of the file locations; for example, if your username on windows is Robert and your username on the Mac is Bob, you may need to change all occurrences of the string “file://C:/Documents%20and%20Settings/Robert/My%20Documents/My%20Music” to “file://localhost/Users/Bob/Music/”. If you didn’t let iTunes manage your files on Windows you will need to do another search and replace (for example, to change “D:\MP3” to the corresponding new location you chose on the Mac).

Before proceeding to the next step, make a duplicate of your newly edited file. If you make a mistake in the next step iTunes will overwrite the file iTunes Music Library.xml, so you’ll want to have a backup on hand in case that happens.

4. Create an empty iTunes Libary file

iTunes really uses the binary file iTunes Library as the database file for your music. However, iTunes will fall back on the XML file when it discovers that the binary file is empty. Unfortunately it does not do this if the file iTunes Library is missing or merely corrupt; in those cases it will delete your old XML file and create an entirely new and empty database. Therefore make sure you have a backup copy of your XML file from the previous step before proceeding.

Run the Mac Terminal app, and type the following command in the shell:

cat /dev/null > ~/Music/iTunes/iTunes\\ Library

This will replace the file ~/Music/iTunes/iTunes Library with an empty file by that name.

5. Run iTunes

Finally, run iTunes. If everything has worked correctly, iTunes will rebuild its database from the XML file and you will be done. If some of your music is missing you probably made a mistake in step three and you’ll need to go back to that step and try again. If all of your music is missing, you probaby made a mistake in step four and you’ll need to restore the backup copy of your edited XML file and start with step four again.

5 thoughts on “How to Migrate iTunes from Windows to the Mac

  1. pjl Post author

    @Holzer: I believe these steps should work pretty much the same if you’re migrating from Mac to Windows, but I’ve never tried that direction. Let me know if it works for you. I have migrated iTunes from one Windows machine to another, however, and I recall having to do essentially the same steps.

  2. muzaklova

    man, you saved my life. It all works now on my new mac – even without moving the files from my external harddrive.

    Only downside: you will lose a lot of the album covers and any history of when you added your music to the library, but I can live with that!

  3. nessie

    Thank you very much for this guide. I found it very useful. There were other guides I found after googling but I chose to follow this one instead because the other guides say I need to set the option “Keep iTunes Music folder organized” which I do not wish to do and I had not set that option in iTunes. So your guide got my attention.

    The play counts and play lists transferred very smoothly. However, there were a few problems with the album artwork as stated by muzaklova. I suspected this could be a problem because iTunes maintains its own artwork database under the “iTunes/Album Artwork” directory. I migrated this directory onto Mac but the artwork on most of the albums went missing. Fortunately, I got them back from after choosing “Get Album Artwork” from the ‘Advanced’ menu in iTunes. This means that if your album artwork is not obtainable using this method, you will need to manually add them back.

    In fact, I was not just transferring my iTunes music library from Windows to Mac. My iPhone was set up in Windows iTunes as well. This guide still served the purpose, except that there were a few extra steps that needed to be carried out:

    1) Migrate your iPhone photos.
    2) Also migrate your iPhone videos and edit the library xml file accordingly.
    3) The downloaded iPhone apps, which are under directory ‘iTunes/Mobile Applications’ also needs to be migrated.

    The iPhones apps will not work automatically and they won’t even appear in iTunes at all. What needs to be done is you need to double click each app in the folder (iTunes allows the apps to be migrated 5 times to a different iTunes setup). Then they will all appear in iTunes.

Leave a Reply