Ask the iTunes Guy: What to do when iTunes goes wild

Seeing strange things in your iTunes library? Kirk McElhearn has a fix.

The iTunes Guy
Credit: IDG

Some of the questions I get about iTunes issues are relatively easy to solve, but others require a lot of time and exploration. In this week’s column, I look at a single question about an iTunes library that seems to have gone back in time. There are important lessons to learn from a problem like this.

My iTunes library has gone crazy

Q: I launched iTunes recently, and the app displayed a dialog saying that it was “Importing iTunes Library.xml.” When this finished, I noticed a number of anomalies with my library. Some music I had ripped recently was no longer there, and some podcasts I had listened to and removed a long time ago were now showing up. I found old playlists that I had deleted long ago, and my newest playlists were missing. What’s going on?

The above is an abbreviated summary of a very long email a reader sent me, which led to a fair amount of correspondence over a few days until we figured out his problem. It’s an interesting issue, and one that I’m going to present in depth to discuss some precautions you can take to ensure the integrity of your iTunes library.

What intrigued me was the fact that iTunes rebuilt the user’s library, which suggested that the iTunes Library.itl file might be corrupted. But the “new” library turned out to be quite old. It was in fact nearly two years old, which gave a clue as to what happened.

When iTunes 12.2 was released in late June 2015, it added a new preference which changed the way the app stored some of its library files. This new option, in the Advanced pane of iTunes’ preferences, allows you to share the iTunes Library XML file with other applications.

itunes xml Kirk McElhearn/IDG

This options tells iTunes to create an XML file from its library file.

iTunes previously had created two main library files:

  • iTunes Library.itl
  • iTunes Library.xml

The former is the file that contains information about your library: the tracks and other items it contains, their play counts and ratings, and your playlists. The XML file was created so other applications (including Apple’s own apps) could read that library to access your media files. But with iTunes 12.2, Apple turned off the automatic creation of this file, since its apps (iMovie, for example) could now read the iTunes Library.itl file to import music into projects.

This XML file was useful for more than just Apple and third-party apps; you could use it to rebuild your iTunes library in case of problems. This technique has saved my iTunes library at times, and it’s one I recommend to people having inexplicable problems with their iTunes libraries.

In the case of my correspondent, the iTunes Library.itl file was corrupt, and iTunes did the logical thing, importing the iTunes Library.xml file that it found to create a new library. However, since iTunes no longer creates or updates the XML file, it was out of date; by nearly two years. The file iTunes loaded was the last one created before Apple introduced the setting to create the XML file. In other words, when Apple changed this behavior—having iTunes create the XML file only when users specifically told it to—it froze that file in time.

iTunes updates the iTunes library.xml file whenever it makes any changes to its main library file. The XML file can be seen as a sort of backup of the iTunes Library.itl file, even though that’s not what it’s meant for. If my correspondent had checked that option in the iTunes preferences, then his library would have been rebuilt using a recent XML file.

My correspondent had a Previous Libraries folder in his iTunes folder, and was able to load a more recent library. But if he had backed up these files regularly, it would have been a lot easier.

macOS includes Time Machine, an automatic backup system that automatically stores copies of your files to an external or network drive. To protect your iTunes library and your other files, it’s a good idea to use Time Machine. This is better than just copying your files or cloning your drive, since it stores multiple versions of your files. If the iTunes Library file in your backup is corrupt, then you’re out of luck, but with Time Machine, you can go back in time and choose different versions until you find one that works.

I also strongly recommend checking the option mentioned above to have iTunes create that XML file. It doesn’t cost you anything, and it can save your iTunes library if something goes wrong.

So make these two changes to ensure the integrity of your iTunes library.

Have questions of your own for the iTunes Guy? Send them along for his consideration.

Shop Tech Products at Amazon