HT201625: Manage and back up your iTunes media library

Learn about Manage and back up your iTunes media library
bromansky

Q: XML Legacy Issues with "External Library"

TL;DR: when shift-opening iTunes and selecting a different library, iTunes Library.xml management and export functions are tied to the default library, not the newly-chosen library.

 

 

I was undergoing a Mac->PC iTunes library conversion, so I moved the whole "~/Music/iTunes" folder over to my secondary drive on my PC "E:\iTunes", included were the xml and itl files.  I shift-opened iTunes on my PC and selected the .itl file on my E: drive, seemingly restoring my iTunes library perfectly back to it's former glory.

 

I haven't been around iTunes for Windows in a while, but it looks like there is some sort of new "Library Management/Home" dropdown under the "File" toolbar in the top left.  I have 2 libraries, "My Computer", which is blank, minus my old empty playlists, and one with no name, which has an "Eject" icon, and contains all the data from my newly-chosen library. 

 

In my excitement, I opened up Pioneer Rekordbox, and changed my iTunes xml location to the one in my E:\iTunes folder, hoping to import all my iTunes data.  Problem is, the xml file only contains data for the default "Library", not my "External" one that I want to use as my primary.  As your support pages say themselves, xml is only still around for external applications like Rekordbox, so I believe this just got missed in the new Library functionality, since all the data is actually managed by the itl file now.

 

I am aware that I could import all the songs into the "My Computer" library, but then I would be losing my precious "Date Added" tags.  That is a mistake you only make once in your life, and I'm not prepared to go through that again.

 

Support ticket with Pioneer: http://forums.pioneerdj.com/entries/63406369-Rekordbox-not-reading-iTunes-playli st-sub-folders

iTunes, Windows 7

Posted on Apr 18, 2015 1:35 PM

Close

Q: XML Legacy Issues with "External Library"

  • All replies
  • Helpful answers

  • by turingtest2,

    turingtest2 turingtest2 Apr 18, 2015 1:42 PM in response to bromansky
    Level 10 (85,368 points)
    iPod
    Apr 18, 2015 1:42 PM in response to bromansky

    TL;DR: When an iTunes library is anywhere other than the default path of user's music the active XML file will normally be called iTunes Library.xml (it takes the same name as the .itl file.) You should delete any iTunes Music Library.xml you copied over when rearranging your library and make sure that your third party tool is accessing the correct XML file.

     

    See Make a split library portable for gory details.

     

    tt2

  • by bromansky,

    bromansky bromansky Apr 18, 2015 2:44 PM in response to turingtest2
    Level 1 (0 points)
    Apr 18, 2015 2:44 PM in response to turingtest2

    The only xml files in the iTunes folder are iTunes Library.xml/itl that are being updated by the minute by iTunes.

     

    Opening the xml file only shows the "This Computer" data, and none of the data from the external library.  I advise you try and examine your xml file and search for a playlist that exists only on your external library.

     

    From the layout of the xml, it looks like there is a 1:1 relationship between iTunes libraries and xml files.  Since there are now multiple libraries within iTunes, how can we have 2 libraries tied to a single library xml file that iTunes is producing?  I believe this is all intelligently handled by the itl file, but Apple seemed to forget the backwards-compatibility of the legacy xml file.

     

    The whole File->Library menu is tied to the local default library, not the selected library.  Exporting when my external library is selected will still produce the xml for the local library.  Going to File->Library->Organize Library and trying to "Reorganize files" is also tied to the library on my C: drive because I did it once, it's now greyed out, and my external library folder structure wasn't changed at all.

  • by turingtest2,

    turingtest2 turingtest2 Apr 18, 2015 3:53 PM in response to bromansky
    Level 10 (85,368 points)
    iPod
    Apr 18, 2015 3:53 PM in response to bromansky

    Checked my active XML. All the playlists are there. In my case the XML is about 5 times the size of the ITL. To make sure you're looking at the right files try the script iTunesInfo.

     

    See the my earlier link for information on library structure. The "Rearrange files" option will be greyed out if the media folder is in the new layout. Information on the layout is stored in .iTunes Preferences.plist inside the media folder.

     

    tt2

  • by hhgttg27,

    hhgttg27 hhgttg27 Apr 18, 2015 4:14 PM in response to bromansky
    Level 5 (5,407 points)
    iTunes
    Apr 18, 2015 4:14 PM in response to bromansky

    I suspect that you are misunderstanding the relationship between the iTunes database (the iTunes Library.itl file) and the XML representation of some of its content.  When iTunes is running it has exactly one library, determined by the iTunes Library.itl file loaded on startup.  Any other libraries that you may be able to see in iTunes will be those on other systems on your local network, via Home Sharing or Family Sharing.  The XML file (which as tt2 notes may be named iTunes Library.xml or iTunes Music Library.xml, based on your configuration) is simply a serialized version of your current library, intended for use by third-party applications.  In normal operations iTunes only writes to the XML file (every time you make a change to the library) - editing the XML file will make no difference to any of iTunes' functions, and will be overwritten anyway when iTunes runs.  You can always delete any .xml files that are in the same folder as the current iTunes Library.itl and will see that one is recreated as soon as you run iTunes again.

     

    If you follow tt2's guidelines regarding Make a split library portable, you'll see that the preferred layout for an iTunes library (especially if stored on an external drive) looks like this:

    Well Formed Library.jpg

    My own master system, which uses this layout, has the complete library on an external drive (K:), so if I check the XML file the information right at the start of the file:

    XML1.jpg

    matches the iTunes Media folder location setting in Edit > Preferences > Advanced:

    Media folder location.jpg

    Similarly, the metadata within the XML file for a single track:

    xml2.jpg

    matches the location information shown using right-click > Get Info > File:

    file loc.jpg

    If you're seeing something different then I suspect that you're looking at an XML file that doesn't match the current library, and/or that your current library is actually the one on your system (C:) drive.

     

    "The whole File->Library menu is tied to the local default library, not the selected library"

     

    There is no difference between these - there is just one active library.  This is selected by iTunes on startup as follows:

     

    • If you SHIFT-start iTunes, this will be the library that you select after clicking the Choose Library... option.
    • If you start iTunes normally, it will use the library that was active the last time it was run unless that library file is unavailable (e.g., on a drive that has been disconnected or its drive letter has changed) - in this latter case iTunes will use the default library in C:\Users\username\Music\iTunes.

     

    Note that double-clicking on a specific iTunes Library.itl file has no impact on these rules - iTunes will start and access the previously active library, even if that is different from the one you've double-clicked on.

  • by bromansky,

    bromansky bromansky Apr 18, 2015 6:02 PM in response to hhgttg27
    Level 1 (0 points)
    Apr 18, 2015 6:02 PM in response to hhgttg27

    I apologize in advance for the imgur links and pictures of monitors.  Turns out if you don't have a "Print Screen" button on your keyboard, it's pretty much impossible to take a screenshot of dynamic rollover text/options in Windows.

     

    iTunes library information:

    http://imgur.com/hRl7v8G

    ITL:  E:\iTunes\iTunes Library.itl

    XML:  E:\iTunes\iTunes Library.xml

    Media:  E:\iTunes\iTunes Media

     

    Folder structure:

    http://imgur.com/IaqRxSk

     

    (I renamed iTunes Music to iTunes Media, but the folder structure is still in the old format [iTunes\iTunes Media\ArtistName\Album\Track])  It seems that the only way to move to the "new" folder scheme is to go to File->Library->Organize, and checking "Reorganize files in the folder 'iTunes Media'".  This seems to only affect the library on my C: drive though, even though I am clearly in the E: library.  If I understood the article correctly, it doesn't seem like the folder structure is vital for the xml generation anyways.  As long as iTunes can choose the library and everything works fine, I would assume that there are no folder structure issues.

     

    "When iTunes is running it has exactly one library, determined by the iTunes Library.itl file loaded on startup.  Any other libraries that you may be able to see in iTunes will be those on other systems on your local network, via Home Sharing or Family Sharing."

     

    So I shift-click on iTunes, and select E:\iTunes\iTunes Library.itl:

    http://imgur.com/kQNNKVD

     

    Still none of my music, I have some playlists, but they're empty.  Clicking on the "Home" in the top left lets me select my "Library".  Maybe we are using different terminology here, but this sure looks like I'm selecting a library from that dropdown.  NOTE: This "default" library does NOT have a playlist called "LIBARY"

     

    Let's select the second one:

    http://imgur.com/NZRqvnT

     

    Perfect, my library.  Note the "LIBARY" playlist. 

     

    So now refer to the previously stated XML file: E:\iTunes\iTunes Library.xml

    http://imgur.com/P1XhTWw

     

    In the "All Items" key, there are supposed to be a lot of references to the tracks, but these playlists are empty.  Sound familiar?  Also, no "LIBARY" playlist?

     

    When checking the "Location" of a track, the field is blank.  Strange.

    http://imgur.com/EA2zHGx

     

    I'll even pitch in my xml file: http://www6.zippyshare.com/v/XOrpRYIL/file.html

     

    Keep in mind that I have 10,000 songs in my actual library, and the xml file shows less than 200.

  • by turingtest2,

    turingtest2 turingtest2 Apr 18, 2015 6:27 PM in response to bromansky
    Level 10 (85,368 points)
    iPod
    Apr 18, 2015 6:27 PM in response to bromansky

    Regarding http://imgur.com/NZRqvnT

    This image suggests you are viewing a remote library which is somehow unnamed. What machine is it running on?


    tt2

  • by bromansky,

    bromansky bromansky Apr 18, 2015 6:44 PM in response to turingtest2
    Level 1 (0 points)
    Apr 18, 2015 6:44 PM in response to turingtest2

    My machine, E:\iTunes\.  Standard Windows install on C:\.

     

    Everything in my iTunes preferences is pointing to this file.

  • by hhgttg27,

    hhgttg27 hhgttg27 Apr 18, 2015 6:50 PM in response to bromansky
    Level 5 (5,407 points)
    iTunes
    Apr 18, 2015 6:50 PM in response to bromansky

    When you see a dropdown like this:

    Home Sharing.jpg

    this indicates that Home Sharing is active.  The "This Computer" entry is always your current, active library.  Other entries are for shared libraries on other devices - usually other PCs running iTunes but may also be NAS or similar devices that offer "iTunes Server" functionality.  Therefore, when you select the second (unnamed) library from your dropdown you are then seeing a library on some other device - confirmed by the lack of file location information ... normally you'd expect to see the name of the remote library here:

    home sharing location.jpg

    but in your case you seem to have a shared library that is unnamed, so this field would be expected to be blank.

     

    I would suggest that you identify where this remote library is located, then follow tt2's procedure in Make a split library portable to transfer this library to your external hard drive.  From the symptoms you've described I suspect that you may have inadvertently combined the media from your actual library (the one you're seeing as remote) with a "blank" iTunes Media.itl file from your new system.  It may also be worth looking through the "official" guidance on How to move your iTunes library to a new computer - Apple Support.

  • by turingtest2,

    turingtest2 turingtest2 Apr 18, 2015 6:53 PM in response to bromansky
    Level 10 (85,368 points)
    iPod
    Apr 18, 2015 6:53 PM in response to bromansky

    This Computer is the library that you select by shift-starting iTunes, and that my script will report on. When you select something else from that control it is another library on the network, hosted by an instance of iTunes running on a different computer.

     

    tt2

  • by hhgttg27,Solvedanswer

    hhgttg27 hhgttg27 Apr 18, 2015 7:05 PM in response to bromansky
    Level 5 (5,407 points)
    iTunes
    Apr 18, 2015 7:05 PM in response to bromansky

    "My machine, E:\iTunes\.  Standard Windows install on C:\.

     

    Everything in my iTunes preferences is pointing to this file."

     

    Common misconception, and one that's not really addressed by Apple's documentation.  The iTunes Media folder location setting in Edit > Preferences > Advanced is not used by iTunes to locate the current content of your library - that information is all contained within the iTunes database.  Rather, the iTunes Media folder location setting is used by the Consolidate Library function (which will move media from the locations specified in the database to that determined by the iTunes Media folder location setting), and when adding new media to the library, in combination with the Copy files to iTunes Media folder ... setting and the method used to add media:

    iTunes Locations for new media.jpg

    Just to repeat from my previous response, when you see this type of dropdown:

    Home Sharing.jpg

    everything listed after "This Computer" indicates a shared iTunes library on another device.  So, if you turn off sharing, these entries will disappear - indeed, if sharing is disabled or there are no shared libraries available on your local network, there will be no dropdown available:

    sharing enabled disabled.jpg

  • by bromansky,

    bromansky bromansky Apr 18, 2015 8:35 PM in response to hhgttg27
    Level 1 (0 points)
    Apr 18, 2015 8:35 PM in response to hhgttg27

    OK I know exactly what's going on now.


    Common misconception is right.  On my mac (source library), I renamed the ~/Music/iTunes folder to ~/Music/Beatport to try and replace iTunes with Beatport Pro.  Too buggy though, so I switched back, but just ended up changing my iTunes Media folder to ~/Music/Beatport/iTunes Music.  All the tutorials and information about library transfers tell you that "the whole library is contained within the iTunes folder", and I presumed the same would apply for this folder.  UNTRUE.  iTunes ended up recreating ~/Music/iTunes and iTunes Library.itl, while the content was in ~/Music/Beatport.

     

    So it looks like the iTunes folder is only self-contained if it's named 'iTunes'.  I ended up transferring an old .itl file which tricked iTunes into thinking it's a shared library with some weird quirks.

     

    Transferred ~/Music/iTunes/iTunes Library.itl instead, xml files are perfect now.  All of my files are on the "My Computer" library, and all my tags have persisted!

     

    The bugged shared library is still showing up in my library list though, even though I deleted everything but my 'iTunes Media' folder and redid the transfer.  I don't really care though.  Another weird tidbit: my library is half-old structure, half-new.  The "artist" files are either in E:\iTunes\iTunes Media OR E:\iTunes\iTunes Media\Music, making for a really messy file structure and a lot of broken links.


    Anyways, the original problem has now been resolved.  Lesson learned: just don't rename folders that are used by applications, also, regardless of your iTunes Media Folder location, the local iTunes library itl will always be in ~/Music/iTunes/ folder.  Restoring the links to the files should be trivial,

     

    Case closed, bookem, Lou.

  • by hhgttg27,

    hhgttg27 hhgttg27 Apr 18, 2015 8:47 PM in response to bromansky
    Level 5 (5,407 points)
    iTunes
    Apr 18, 2015 8:47 PM in response to bromansky

    " Lesson learned: just don't rename folders that are used by applications"

     

    As far as iTunes is concerned, 100% correct - tt2's previously referenced user tip describes the operations that you can perform without affecting the integrity of your library.

     

    "regardless of your iTunes Media Folder location, the local iTunes library itl will always be in ~/Music/iTunes/ folder."

     

    No.  You can put the iTunes Library.itl file anywhere you want it to be.  Of the four systems I regularly use iTunes on, only one of these has a library on the system disc/default location - the others all have a well-formed library on an external drive, and don't even have a C:\Users\username\Music\iTunes folder.  The key to the "portable" layout is that you have one folder (typically named iTunes) that contains the iTunes Library.itl file and the iTunes Media folder.  As long as the relationship between the database file and media folder is preserved this structure can be anywhere on your system.  Also, there is no concept of a "local" iTunes database - much better to think of there being:

     

    • the "active" library database - which can be anywhere you want it to be, and
    • the "default" library database location, which will apply for any fresh install of iTunes or for the case where the active library from the last time iTunes was run cannot be found - this is C:\Users\username\Music\iTunes.
  • by bromansky,

    bromansky bromansky Apr 18, 2015 9:39 PM in response to hhgttg27
    Level 1 (0 points)
    Apr 18, 2015 9:39 PM in response to hhgttg27

    Thank you for the concise explanation and quick replies.