I am using iTunes as my main music player software for about 5 years now. In that time I had to move and restore my growing iTunes library more than 10 times. It can become quite a job to get it done properly so I came across this great howto article to help you and me out in the future:
“I see some discussion about fixing busted iTunes libraries, either when moving one on the same computer or migrating to a new one. Here’s what I have found works for me. Bonus: no slow AppleScripts or payments (donations cheerfully accepted and squandered).
First, what I have discovered about how iTunes manages music collections. There are two files it uses, one that is binary (ie, machine readable for faster performance on searching, sorting, add/edit/delete operations) and one that has the same information but in a human readable format (for a certain subset of humans who can read XML natively). The XML file is written from the binary file as a backup (check the dates to confirm).”
But that isn’t were it needs to stop. I had to do some more things with my iTunes library lately – like extracting all that ratings and exporting them into a new music player software I liked to test. I therefore wrote myself a little tool in C# that does the job of reading in the whole iTunes library and giving you programmatically access to that library. It only needs to have read access to the Mediathek.xml file iTunes stores in it’s music folder and you from there on can work your way through the bazillions of music tracks you may or may not have in your library. It even does the find-and-replace job a bit easier than the solution mentioned in the article above.
I release the code under the CC-Attribution-NonCommercial-ShareAlike 3.0 license and here is your download:
This code is a simple example of how to use the XmlTextReader in C# and how to traverse through them. It should be easy to understand and easy to change. I would love to hear from you when and if it helped you.
Source 1: iTunes library, fixing a broken one or moving one
Source 2: ReadiTunesMediathek.zip (11,82 KB)