Multiple Library Confusion
If you use iTunes' multiple library feature it is possible for your system to get confused about where your current selected library is located. Here are some thoughts and tips to alleviate the confusion.
The Basics
When iTunes is first installed, it creates several support files and folders in your [username]/Music/iTunes/ folder:
- a database file, named "iTunes Library.itl"or "iTunes Library", without an extension, before iTunes version 10.4. This is where iTunes stores all the information about your tracks and playlists. (iTunes is, afterall, pretty much a database manager with a music/video player nailed on.)
- an XML file, named "iTunes Library.xml" or "iTunes Music Library.xml". This XML file is periodically updated by iTunes and contains meta-data information about tracks and playlists and stuff, but, despite what appears to be a common myth, iTunes does not use it. It is there primarily so other applications can access information about iTunes (GarageBand, iPhoto, apps using the Media Browser, and so on).
(Note: an abandoned "iTunes Music Library.xml" may still be in the folder alongside the newer "iTunes Library.xml" file. If so, iTunes will ignore it. iTunes version 10.8 and later should be generating the "iTunes Library.xml" file at installation.)
Also created is an "iTunes Media" foldernamed "iTunes Music" for versions of iTunes prior to 9.0. This is the default location for files when they are:
- imported to iTunes from CD
- converted from existing tracks
- purchased from the iTunes Store
- andif "Copy files to iTunes Media folder when adding to library" is checked in iTunes' Preferences > Advancedwhen files are otherwise added to iTunes.
The "iTunes Media" folder can actually be re-located anywhere and renamed via Preferences > Advanced (although one would still refer to it metonymically as the "iTunes Media" folder, even if it was named "Supa Monsta Killa Musica Extravaganza").
Of course, there is an Album Artwork folder. iTunes 8 added the iTunes Library Genius.itdb and iTunes Library Extras.itdb files. And perhaps there are files or folders leftover from previous incarnations of iTunes, such as an iPod Games folder and "Previous Libraries" folder. Files that iTunes actually uses will have recent modification dates.
Multiple Libraries
When iTunes introduced multiple library managementwith iTunes 7 in September 2006it enabled users to create separate database libraries that didn't have to be in your [username]/Music/iTunes/ folder. Essentially, when this feature is invoked (by holding down the Option key when launching iTunes) iTunes can create or open another librarythat is, another set of the support files and folders I listed abovein a different location. Your current "iTunes Media" folder remains where it is, although a new empty "iTunes Media" folder is created in the location you selected.
Additionally, the file path of the most recently loaded iTunes multiple library's XML file is stored in a preference file. This file is [username]/Library/Preferences/com.apple.iApps.plist. This preference file may also contain pointers to your iPhoto library, and perhaps similar information for other applications. This file is made available so that other apps, if they need to, can locate the most recent database files for iTunes or iPhoto. And as with its XML file, iTunes doesn't refer to this file either. It is for the enlightenment of other applications.
Additionally, as of iTunes 12.2, the Advanced pane of iTunes Preferences has a setting to "Share iTunes Library XML with other applications" [screenshot]
When this is checkmarked OFF, the XML file is not written out and the iApps.plist file will not have a pointer to its location.
According to this Apple support document, this setting is unchecked by default after installing iTunes 12.2 or later (such as you might during a clean install of the operating system).
How Confusion Can Ensue
Some of my AppleScripts for iTunes use a routine which reads the iApps.plist in order to obtain the location of the current iTunes library's XML file in order to get information from it. I often get reports that these scripts don't seem to be working correctly; that the information seems to be wrong or doesn't correlate with track tags in iTunes. When the Correspondent and I investigate this phenomenon, very often it is because the iApps.plist contains the wrong location for the current iTunes library.
(A possible bug after updating to iTunes 11 may also cause the iApps.plist to "forget" the location of the XML file. This is described here.)
I must admit that I am not certain when the [username]/Library/Preferences/com.apple.iApps.plist file gets updated with the location of the current iTunes library. But that may be neither here nor there. What does appear to be consistent among most of these Correspondents is one or more of these factors:
- They use the multiple library feature, knowingly or otherwise, or...
- ...have manually (and wrong-headedly) moved the support files from the default location in ~/Music/iTunes/.
- Their "other" library is located on an external drive or server.
- They use a notebook computer and/or an external drive/server is frequently unmounted and mounted.
So, what appears to be happening is that the iApps.plist file is erroneously updated with the original default location of the XML file and not the location of the XML file for the multiple library they most recently used on the external drive. Or visa versa.
There can be other extenuating circumstances: Frequently reported is that users have forgotten that they ever used the multiple library feature not realising that the multiple library they established will continue to be their default library until they Option-start iTunes and select another. In other instances, an external drive containing the database files and/or the "iTunes Media" folder may not be mounted when iTunes is launched. This obliges iTunes to fall back on the default (and wrong) files in the [username]/Music/iTunes/ folder. Other symptoms involve convoluted sharing set-ups or having moved, copied, or aliased (or symlinked) files or folders from the default [username]/Music/iTunes/ folder rather than follow Apple's instructions for moving an iTunes Media folder to a new location. Heck, I don't know what people are doing at their house. But the result is that the supposed "official" location to the current iTunes database files is erroneous.
(With the exception of the "iTunes Media" folder, I think these support files should be removed from ~/Music/iTunes/ and hidden away in the user's Library directory. There's no reason for a user to ever have to access them.)
ANYway...
If you suspect a disconnect between your current iTunes library location and what the iApps.plist maintains, you can easily open the iApps.plist with QuickLook to confirm a problem. (Property List Editor.app or Xcode will open it also.)
And here is what I have recommended to users to correct the problem (but please use caution following this tip. It has worked for virtually everyone I have recommended it to, but I can't make guarantees on how it will result at your house since I don't have your details):
- Make sure the drive that contains your multiple library folder is mounted. Quit iTunes. Wait until it is definitely totally shut down.
- (At this point I might have suggested that you trash the iApps.plist file, however, if this file also contains a non-standard location for your iPhoto library, then this might be lost if you trash the plist file.)
- Start iTunes while HOLDING DOWN THE OPTION KEY. When it asks you if you want to open or create a library, choose open and navigate to the multiple library folder on the external drive, select it, and click OK. In a few moments, iTunes should be up and running.
- To be sure the iTunes database is updated, create an empty playlist and give it a name, drag any track to it, play that track in that playlist for a 10-20 seconds or so, stop the track, and delete the playlist (the track will not be deleted).
- Quit iTunes again, wait for it to shut down, then restart it NORMALLY. That should be enough for the database to be updated.
- Check the iApps.plist to see if it reflects the correct database file location.