 So, you have a new computer, of have any other reason to move your iTunes library to another computer. iTunes has a built in function that's called "Consolidate Library" which is really meant to collect all files in your libraries under one directory whould you have stray files. It can be used to move your iTunes library around on your disk or to an external disk, but it assumes that you're still using the same computer since the new location will be in relation to the current computer. So Consolidate library won't work for us, when moving to a new computer.
FireWire Target Disk Mode
So what will? Well, I did it this way to make it work. As it were, I wanted to move my library from my Mac Pro to my MacBook Pro to have it with me all the time. So I attached the MacBook Pro to my Mac Pro using a Firewire cable and booted the laptop to firewire target disk mode, which means it turned up on the Mac Pro as a external drive. there I dragged the ~ /Music/iTunes folder from my Mac Pro to the correlating folder of my laptop. After about an hour the copy was complete (yeah, thousands of songs) and I disconnected.
Missing Files
Upon booting my laptop I found that over half of all the files were still associated with the files on my old Mac Pro, but the other half worked fine on the laptop. I can't explain why this was the case, but there were about 2000 songs that were missing in the library, even though they were on the disk in the place it would seem obvious for iTunes to find them.
AppleScript?
Well, using an AppleScript I managed to find out what tunes that were missing but I quickly learned that I can't update the location using AppleScript since that is a read-only attribute. Ok, so what now?
XML to the rescue
Well, turns out the solution was pretty simple. I just use the built in command to export the iTunes library to an XML file to ~/Dekstop/Library.xml
Step two is to remove (or rather, move) two files from the iTunes directory: ~ /Music/iTunes/iTunes Library (binary) and ~/Music/iTunes/Tunes Music Library.xml (xml)
Step three is to open the ~/Desktop/Library.xml (the one we exported) in a text editor and use search and replace to update each path accordingly. In my case it meant replace every occurrence of "file:///Volumes/Delusion/Users/..." with just "file:///Users/...". Then save the XML file.
Now launch iTunes. What happens is that it doesn't have a library file so it doesn't show any music. This is all good and well, because the next step is to use File->Import... to import the update ~/Desktop/Library.xml
The last step may take some time depending on your music collections size, but it goes through the xml file and adds all the music files in it, but copies nothing since it's already present in the correct place.
It also goes through the usual process of determining gapless playback information and such, and also tries to sort all the files internally. All in all this process took me about five minutes for 5000 songs.
When it's done, you have your library as before, it even keeps the "date added" *order*, meaning that they will all have the date added be "today", but in the order you added them before, so any smart playlists ordered by "date added" will still work as before. Any smart playlist that depend on date added being in a particular date range will be broke.
|