How To Rebuild Your iTunes Library

Note: Since iTunes 12.2, iTunes no longer creates the iTunes Library.xml file, which I mention below, by default. It’s a good idea to tell iTunes to do this, so you can recover your library from that file if necessary. To do this, go to iTunes > Preferences > Advanced, and check Share iTunes Library XML with other applications.

Every now and then, an iTunes Library has problems. You may have tracks or songs that disappear in the library, but that are still in your iTunes Media folder. Or playlists may change or disappear. Or there may be other, inexplicable problems.

One way to try and fix these issues is to rebuild your iTunes library. I’ve done this from time to time, and it can solve some issues, and has even fixed problems with Genius.

It’s a simple process, but one that may take a while if you have a lot of content in your library. Here’s how you do it.

  1. Back up your iTunes Media folder. While rebuilding the library doesn’t affect your media files, it’s best to be safe.

  2. Quit iTunes, then find your iTunes folder. If you’re on a Mac, it’ll be in the Music folder in your home folder (that’s the one with the house icon and your user name). On Windows, it can be in different locations according to the version of Windows you use:

  • Windows XP: \Documents and Settings\[your username]\My Documents\My Music\
  • Windows Vista: \Users\[your username]\Music\
  • Windows 7 or later: \Users\[your username]\My Music\

The two files you’ll be using are iTunes Library.itl (or, perhaps, just iTunes Library) and iTunes Library.xml.)

Itunes library files

  1. Make copies of all these files; again, just in case.

  2. Move the iTunes Library.xml or iTunes Music Library.xml file to your Desktop or to another folder. You’ll be using this file to rebuild the library.

  3. Delete the iTunes Library or iTunes Library.itl file by moving it to the Trash or Recycle Bin.

  4. Launch iTunes, and choose File > Library > Import Playlist. Navigate to the iTunes Library.xml file you moved earlier, and click Choose (Mac) or Open (Windows).

iTunes will now examine the XML file, finding all your tracks and playlists, and add them to your library. This will create a new iTunes Library.itl file. If you have a lot of content in your iTunes library, this will take a while. The last time I did it with a library of about 70,000 tracks, it took well over an hour, so be patient.

If for any reason it doesn’t, you can always quit iTunes, delete the newly-created iTunes Library.itl file, and replace it with the one you backed up.

One thing you’ll notice is that all the view settings you applied have changed. You’ll have to go back and reset them the way you want for each playlist. (Choose View > Show View Options to tweak these settings.) But the new library should contain all your media, and all your playlists. Also, the Date Added for all your iTunes content will be the date on which you rebuild the library.

Learn how to get the most out of iTunes with my ebook, Take Control of iTunes 12:

131 thoughts on “How To Rebuild Your iTunes Library

  1. Hey Kirk, super timely article as the Genius Bar had to do a fresh reinstall of Yosemite on my Mac Mini media server – long story. So I’ll be doing just what you said above. A couple of question, though … I have a Time Machine backup of my Mac Mini but I don’t want to reinstall everything – just the iTunes files you mentioned above, because all of my tracks are on a separate hard drive

    Is there a way to get at those two files on the Time Machine .sparsebundle from a different Mac? I’d like to know I have them saved elsewhere before I begin. When I attempt to explore Time Machine from my other Mac, it only allows me to explore the sparsebundle for that Mac – not my Mac Mini sparsebundle.

    Thanks for any assistance you can offer & for posting this when you did.

  2. “Every now and then, an iTunes Library shows problems. You may have tracks or songs that disappear in the iTunes Media folder, but that are still in your library.”

    _This_ is the real problem. The discussion in shows that a lot of people are affected, that nobody has a clue, and that Apple does not even seem to take note. This is the real scandal: iTunes randomly deleting your files.

  3. I cancelled the rebuild, having left it alone while I returned to the second half of my work day. When I got home again, a dialog was present informing me of what I already knew: The is insufficient space on my boot drive for all my media. Of course, that’s why I moved the iTunes Media folder to an external drive. The kicker: The dialog advised that it would copy as many of the files as possible to my boot drive. That’s why I cancelled the process. I Trashed the two files it had created and replaced them with the old files I had backed-up. All is well. Is there an alternate process to rebuild those files with the iTunes Media folder on an external drive? (Mac OS X 10.10.2) TIA! :)

    • If your media is on an external drive, what you have to do is, after you watch iTunes, go to the Advanced preferences, and select your iTunes Media folder. Import the XML file after doing that.

  4. Hi Kirk, thanks for this article. I have a quick question: does rebuilding the iTunes library reset play counts and/or change which tracks are checked/ unchecked?

    • It retains play counts and last played dates, but changes the date added. As for checked tracks, I never looked at that. You can try it, keeping your old files, and if it doesn’t work, then quit iTunes and put the old files back.

      • Hmm … not too sure about “but changes the date added”. I just rebuilt my Library, after I read your helpful article, and thankfully the Date Added metadata remained the same. I use this field quite a bit for sorting.

        • Every time I’ve done it iTunes changes the Date Added to the date I rebuilt the library. If that didn’t happen to you, I’d be very curious to know what you did.

          • Well, I pretty much followed your instructions … or at least I thought I did, until I just now reread your instructions. And now I realize I did not completely follow your instructions.

            Here’s what I did instead:

            1. Because of my circumstances, I copied my critical files from my Time Machine Backup:

            iTunes Library.itl
            iTunes Music Library.xml
            iTunes Library Extras.itdb
            iTunes Library Genius.itdb

            2. Since my Mac Mini media server had to have a totally fresh install of Yosemite, I launched iTunes, and made sure iTunes was in a virgin state – no music, no nothing.

            3. I quit iTunes, went to the Music folder and dragged out the files above.

            4. (I think this is the critical difference between what you recommend and what ended up doing). I replaced each of the files above with the original files from my Time Machine backup.

            5. I made sure that the path name to my external USB music drive was ‘exactly’ the same – this is critical.

            6. I launched iTunes … and low and behold, everything was exactly how it had been prior to my Mac Mini’s operating system meltdown – including the precious Date Added metadata.

            I was one happy camper …

            In short, I did not do your item #6:

            “Launch iTunes, and choose File > Library > Import Playlist. Navigate to the iTunes Library.xml file you moved earlier, and click Choose (Mac) or Open (Windows)'”

            But simply replaced each of my critical iTunes files with my previous ones – making sure the path to my media was identical to what it had been prior to my system rebuild.

            Hope this helps.

  5. Right, that’s not the same. You simply restored the library from a backup, you didn’t rebuild it. Rebuilding is more a troubleshooting thing. And, you did the right thing for your specific problem.

      • As I explain in the article, rebuilding the library is for troubleshooting: when iTunes isn’t working correctly. In your case, you wanted to simply go back to an earlier snapshot of your library, and that’s what Time Machine backups are for.

    • Ok, that makes sense. Thanks. And thanks also for the article which got me setup to rebuild my iTunes media library – it’s scary seeing 10,000 tracks disappear!

  6. I got a new drive, so I have to reinstall it. I’ve been using this method for a while, but when doing these steps using iTunes 12, I find my Podcasts are get moved to Music.

  7. Well described. I somehow crashed my itl-file and had to rebuild with the xml. Worked fine, but I really like to have my “date added” like before. I have lots of playlists based on that date. Isn’t there an option to tell itunes to use the xml data or edit the itl file or anything else.

  8. Thank you so much! I could not get my iTunes Match to sync. I kept getting a 4010 error regarding Genius. After weeks of sifting through different community postings, I found yours today. It was the only one that worked!

  9. “4. Move the iTunes Library.xml *or* iTunes Music Library.xml file…” I have BOTH of these files. So which one do I move? (The “Music” one is not mentioned anywhere else.)

  10. My itunes folder is over 100 gigs. I want to rebuild the library. I have itunes match. Can I remove all the files (how?) then rebuild my library and then re-download all the music files? Thanks!

  11. Hi, I’m also curious to know if doing this will impact iTunes Match and involve needing to re-upload all my (unmatched) tracks – 15,000 and counting!

    I’d be grateful if you could let us know.

    • I don’t think it should be a problem. iTunes should be able to spot that the tracks in your library match what’s been uploaded. But, hey, with iTunes, you never know… :-)

  12. Thank you, Kirk! This helped enormously. For years I’ve had a problem free library that’s very large (22k items and counting). Since, they launched Apple Music, I have had big problems, resulting in a corrupt library. This was the fix after visiting many other threads. Thanks again.

  13. I followed the instructions (I think) and when I added the XML file back into iTunes, it added all my iPhone apps, books and movies and listed a lot of the tracks as separate albums. Not sure what I did wrong or how to correct this. The apps section of iTunes is empty. I can re-download them via the App store but still. What a mess. Any ideas?


  14. Kirk, I tried this and it duplicated all my playlist and looks like all my songs. I did notice that iCloud was “running” in the background. Any ideas before I give it another whirl?

    • If you have iCloud Music Library active, then that will add everything to your library that’s in the cloud. I’m not sure that rebuilding a library with iCloud Music Library is a good idea. You’d need to delete everything from the library (after making a backup, of course), update iCloud Music Library, then rebuild the library.

  15. I tried this as well and all has worked except it rebuilds information only for the albums I have purchased via itunes and not the albums that I’ve ripped. Anyone know what went wrong?

  16. Thanks for this helpful, informative post! Took me a second to find the Import Playlist option as the menu bar is hidden by default (at least in 12.3.2). Worked like a charm. I also moved my music library at the same time, so ran a find/replace on the xml file to clarify locations. Really appreciated your post — took a lot of the guesswork out of it for me.

  17. Hey Kirk, I was hoping that rebuilding would help me. It did not. Do know if iTunes has a limit on video files? I have (on an external Drobo) 16.2 TB of music, movies and TV shows. That is 35,326 songs in music, 2,390 Movies and 19,568 in TV shows. I have been trying to add TV shows but a couple enter in (or appear to) and then iTunes locks up and locks up the Drobo. I need to shut down the Drobo an then restart it and then restart iTunes. I have re-installed iTunes and then re built it as you proposed but nothing works! Any ideas? Or is it just too much for iTunes??

    • I don’t think iTunes has a problem with that number of items. It’s not the size that iTunes cares about, so that’s not the issue. However, it could be either your network or the Drobo itself that’s choking.

      • Dear Kirk, Thought it might be my Drobo so I loaded 3TB outside the iTunes folder and was able to use and access it fine and iTunes worked that same way. The Drobo is connected via firewire 800 so I don’t understand how the network would do anything? Any other ideas?

        • Sorry, most people who have a Drobo or similar device access it over a network. FireWire 800 is pretty slow, still. I’d look for the problem being with the Drobo; have you tried Drobo forums or support?

  18. Kirk, I did the rebuild and it solved the problem of getting an endless “preparing to copy” msg whenever I tried to consolidate my iTunes to my library in an external drive (connected via USB 3). So that is good and thanks. However, a number of my saved podcasts have been moved to the Music section, and in the Podcast section there many many extra listings for the same podcast show on the left column – for example there are around 7 for the Best Soccer Show, 6 for On The Media and 40 (!!!) for TEDtalks where there had been only one each before i did the rebuild. And I can’t delete these “phantom” podcast listings, which seem to contain one episode each, although I can’t listen to them or trash them. what can I do? Im on a 2012 Macbook Pro Retina running El Capitan.

    • Well, you can change them back to podcasts. Select them, press Command-I, then on the Options tab, change the Media Kind to Podcast. That should fix things, though the feeds themselves might still be messed up.

      • Thanks, Kirk. Well, while not solving the problem, that does make things clearer. Apparently all the podcasts that got switched to Music were the ones that came from the empty phantom duplicate feeds. Choosing “podcast” media type as you suggested looks like it puts them back under those feeds. But I still have many many duplicate feeds instead of all the episodes from the same podcast under a single listing. And here is the crux – when the iTunes rebuild moved all these podcast files to music, it also left the emptied out feed subscriptions LOCKED on “off.” Apparently I can’t delete these feeds (or turn them on) when locked. Ive been scouring the internet but can’t find way to get rid of the little padlock icon. Others have reported this issue as well. Any suggestions?

        • I’ve never encountered this, nor heard of it. If you can, post a question in my forum (there’s a link in the sidebar at the left) with screenshots, showing exactly how the podcast feeds display. Maybe someone will have an idea.

  19. To be clearer, when I say “listing” I guess the actual term is podcast “feed.” I did find that I can delete the phantom episodes contained in each of these feeds by scrolling over and getting the little circle with three dots, but then it says “There are no episodes in this podcast feed” while the feed listing itself remains. Clicking “delete” on the three dots on the feed itself does nothing.

  20. Kirk – Have you checked to see if rebuilding the library helps address the iCloud Music Library issues with metadata corruption. If removing all the cruft from an old library improves the iCML experience?

  21. I moved my library to a new external drive. I made a clone of the original iTunes music we had on one external drive to another using Carbon Copy Cloner. I turned on iTunes and pointed it to the new drive. It updated the library and then it organized all of the files.
    When I tried to consolidate the files the first time it said preparing copy for over 35 hours before I hit stop.
    All of the songs have exclamation points. I tried the above suggestions and it starts iTunes as if it was brand new and there are no songs showing at all. I click on library add playlist click on the Library XML folder on the desktop and I get Error -50.
    Any suggestion on how to make iTunes see all the songs on the new drive? There are about 400K songs and 4TB worth of music. Having to tell iTunes where to find each and every song is not doable.

    • It broke because you didn’t let it consolidate. So you need to start over. I assume you have a backup, right??? If it says that it’s going to take 35 hours, that’s just an early estimate; for 400K tracks it might take a few hours, but not as long as that. (I seem to recall the last time I did it on my 70K-track library it was at least 30-45 minutes).

      • It did not give us an estimate of how long it was going to take to consolidate. After 35 hours of preparing copy we hit stop.
        We have back-ups of everything and will try again this morning.

        • Oh, the way you said it, I understood that it gave an estimate of over 35 hours. That is a long time; however, it may take a long time for that many files.

  22. The reason I need to rebuild my library is because iTunes keeps cutting off the ends of newly imported songs (I have confirmed the songs are fine, it is iTunes that is the issue since they play fine in iOS). My biggest worry is that after the rebuild I will lose all of my metadata (stars, play count etc) I have been building this metadata for over 10+ years and I don’t want to lose it. Can anyone confirm that with this rebuild I won’t lose that metadata?

    • You won’t lose anything. But it’s not a library issue that’s cutting off tracks. Does this happen to all newly imported tracks?

      • Thanks Kirk, no it doesn’t. I have a couple of albums I got from another download services and they are 320 mp3 and with like 3 of the albums almost all of the songs get cut off with about 60 sec left. I can actually see the playhead skip to the end and then it ends abruptly. What is interesting is that if I skip to halfway through the song the song ends like it should in iTunes, so it seems to only happen when they are played from the beginning.

        I checked the songs in QT and they play fine from beginning to end.

        They also play without issue on my iPhone.

        I have read that this is a random problem that can happen, and everything I have read says to do a rebuild and it should fix the issue. But if you have another suggestion I am all ears. This happened to me last year with an album and the only fix I had was to just buy the same album again in iTunes which was frustrating.

        Also for the record I have deleted, and imported from the file menu instead of dragging and dropping on the iTunes icon and it doesn’t fix anything. Also the start and stop times in options are not checked.

  23. Any suggestions for what to do when it’s the XML file that’s corrupt? Mine includes references to files that don’t exist.

    • It still might be better than the .itl file. You might be able to remove those files in iTunes (assuming you can’t now).

  24. I’m currently on iTunes 12.4. Could I rebuild my iTunes library in a lower version of iTunes, say 12.1, without losing all of my ratings, plays etc.?

  25. The problem I have is that I don’t have the .xml files. I am migrating to a new Windows machine (7 Pro) and copied my library to external drive then moved it to new PC. I have the .itl file but not the .xml files. And don’t know how to make a new one/find old one.

    Any ideas?


    • Go to iTunes > Preferences > Advanced, and check Share iTunes XML with other applications. If that’s not checked, then it doesn’t create the XML file.

      Oh, sorry, Windows; I think it’s Tools > Options > Advanced…

      • So late last night I got the XML file back, but I still can’t get my media files to show up in iTunes. iTunes wouldn’t let me point to the regular path, so I had to rename my “My Music” folder to “Music”. Even with the XML and .itl library files where I have iTunes pointing, nothing populates.

  26. Hello Kirk! Thanks so much for your article. My issue is that my itunes itl file is from 2008 and I receive this message The file “iTunes Library.itl” cannot be imported because it does not appear to be a valid exported file”. When I open itunes, my music is missing. Can you help?

    • It’s certainly not the .itl file you’re currently using. That file gets updated every time you play something. You need to find the current library file. Search for other .itl files on your computer.

  27. I also have no .xml file. (Running El Capitan, iTunes 12.5) Went to Advanced preferences and checked “Share iTunes XML with other applications” and restarted. Sure enough, there’s a .xml file now . . . but it’s a DreamWeaver file! Tried it twice and it keeps coming up that way. A glance at the contents appears to show coding for iTunes songs, but I have no way of knowing if it’s complete.

    Should I try your procedure, moving the DW file to the desktop?

    • It’s not a Dreamweaver file; it’s just that it shows a Dreamweaver icon, because you have that app installed, and it’s seeing an XML file as part of a web project. Follow the instructions regardless of the file’s icon.

  28. Also, iTunes now displays only those songs & albums purchased from the iTunes Store. I know my uploaded CD files are still in the system, because I can call up titles I know. But how do I get them back into my iTunes window?

  29. Hi, I followed the instructions for getting rid of shuffle in iTunes 12.5, but after I imported the new xml/itl file, my playlists doubled-up (2 of every playlist). I followed the instructions to the letter, what went wrong? I really want to get rid of this shuffle business1

  30. I am running itunes on a Macbook with Mavericks OS.
    I want to load some new music from Itunes Store but I can’t for the life of me find how I can Add a Playlist!!!!! Its not down the bottom like it used to be.
    Anyone help out?

  31. After doing this rebuild with iTunes, the star ratings for thousands of tracks are gray and can’t be changed.
    Only about a hundred tracks out of nearly 20,000 have black stars.
    This is unacceptable and there’s no way I’m going to lose years of ratings.
    I’ll now have to replace the old file and find another way to squash the bug in my library.

    That file BTW, is now just named “iTunes Library” with no extension, not “iTunes Library.itl” as shown above.

    All the podcasts were restored in the Music tab, not in Podcasts. I had to select them and change “Options>media kind” back to Podcast.

  32. We’re in the process of switching from a Thunderbolt external drive to a USB external drive (Thunderbolt keeps disconnecting from laptop…are all Thunderbolt cables junk or have we just been unlucky?).

    The directory for the iTunes is probably messed up because of constant ejections of the Thunderbolt drive. The boxes are clicked to keep a copy of files in the Media Folder, but when I move the iTunes folder to the new drive and open iTunes (pointing it to the new location) all of the songs are exclamation points. The library will not consolidate down.

    We are now trying the method above. The first time I started this it worked perfectly, except I forgot to tell iTunes to put the new library on the external drive. After about 35,000 songs it ran out of room on the laptop. I cancelled the process, deleted the new files, quit iTunes and started over. This time I pointed it to the external drive.

    It has been saying “Importing Playlist” for about 2 hours, but there is no change that I can see happening. Should I trust it is doing something in the background or cancel again and restart? There is about 5TB of music, so I don’t expect this to happen quickly. The first time it at least showed a progress bar.

    • 5 TB of music is going to take a very long time. Is this USB 2 or USB 3? The former could take more than 24 hours; the latter, maybe 6- 10 hours.

  33. It is USB 3.0. iTunes said an unknown error occurred (~50) and stopped importing after 1TB. We quit and tried again same thing almost instantly. Any suggestions?

    We could try doing all of this with a rebuild on the Thunderbolt drive and not move the laptop if that will make the import faster and better. We would prefer to use the Thunderbolt drive, but the cables all seem to be incredibly sensitive and only work for a few days. We’re not being rough with them, just moving a laptop from table to lap and back.

    • Hmm, that’s odd. iTunes may have problems reading the disk. Maybe you should run a disk check with Disk Utility.

  34. Hi Kirk; is this procedure still current? I tried it and now iTunes is not showing much album art, no Apps, no Tones, no Audiobooks. I have all that content in folders of those names in the iTunes folder.
    Is there a nuclear option? ie take everything out of the Music > iTunes folder, relaunch iTunes, then drag each folder back in?
    I’m only trying this since I’ve purchased albums in iTunes last few days and they did not properly download, were indicated as corrupt, yet still showed up in iTunes despite right-click delete from Library as well as dragging the music’s folder in Finder to the trash and emptying, quitting app, rebooting mac etc. That and other long term general wonkiness with books also.
    Would not mind a fresh new start.
    Many Thanks, dave

    • Sounds like you do need the nuclear option. Delete everything from iTunes, but don’t move the files to the trash. (And perhaps make a backup of your iTunes Media folder first.) Then drag the iTunes Media folder onto iTunes, and it will load everything. You’ll lose metadata such as play counts and ratings, and you’ll lose your playlists though.

  35. Thanks for the quick reply Kirk; is there any way to preserve and reinstall the playlists? I’ve developed them over many years since first using iTunes when it came out, some have sentimental value, others I wouldn’t be able to recreate from memory…
    Counts and ratings are no big deal for me.

    • The XML file contains that stuff. Maybe try again.

      If it’s only certain types of media that aren’t showing, you can drag their folders onto iTunes to add them.

      • Hi Kirk; Ok, so I went ahead and made backup copies first, then removed all the content folders from the iTunes folder. Updated iTunes. launched and told it to import the .xml playlist file, then added content folders back into the iTunes folder.
        Moved Books folder out, found the iBooks books folder, deleted its contents, opened iBooks and imported all the Books folder contents, and now both iTunes and iBooks seem to better represent my content.
        The only glitch I’ve seen now is that iTunes Music, in Albums view, includes my Podcasts.
        So I’m starting to delete those from the Albums view.
        Might find other glitches going forward, and am still to worried this has actually worked until I reboot, then I may try syncing iPhone and iPad and resuming normal ops.
        Filed an inquiry with Apple about problems with an album download, for the second time. First time they did not respond within 48h as promised.
        Anyway, that’s the update, thanks for the help, content seems to be there and the playlists so far so good!

        • Hey Kirk; another follow up. iTunes is really getting wacky. ‘Recently Played’ smartlist was not showing recently played items. iPhone says it is not syncing Music, yet Audio is the largest chunk of storage use. There are unremovable videos, music I don’t recall adding, that is not music I’m interested in, etc. Really lots more goofed up things.
          What I’d like to do is preserve the playlists and recreate them after nuking the library.
          What’s the easiest workflow for that? export individual playlists as xml, or text, then refer to that when creating them in the fresh iTunes? or export the whole library of playlists?
          It’s going to take hours and hours but I’m really frustrated with the mess and realize it needs to be done, a bit each day…


  36. Hi Kirk;
    That last rebuild didn’t solve issues.
    Today I exported all the playlists I want to keep and took all the files out of Music > iTunes and deleted iTunes folder. Went into my account folder and deleted a bunch of iTunes related files. Tried to delete the iTunes app but got a warning that it’s required by MacOS.
    Launched iTunes again and it created a new iTunes folder and… decided I have 174 albums in my library. Although there are none in the iTunes folder and my Library and itl and xml files are moved to another folder and it should be looking at a brand new fresh and empty itunes folder.
    Wot the hey? I am really sick of this and would like to nuke/delete iTunes and all its associated files, re-download it and manually drag in all the content that I moved out a little while ago and then start bringing in the playlist xmls.
    I have the feeling that is the only way to get it to behave correctly again. Everything else I’ve tried still leaves iTunes with plenty of flaws. Enough that I don’t want to update any iOS apps, buy anything, or even sync my phones/ipad with it. (iCloud sync of those is out of the question).

    • Are the 174 albums in the library purchased from the iTunes Store? By default, iTunes shows all your purchases when you create a library.

  37. Many Thanks Kirk! Good thought… but, uh… hm…
    Account > Purchased doesn’t give a count… there is a long list on the left and only a few “Recent” albums. No apparent way to get a count of all. “Recent” Songs, scrolling to bottom, is 250.
    iTunes Library > Albums, View > Only Downloaded Music shows No items in Grid or List view.
    Switching to View > All Music and View as Grid shows the 174, consuming 7.62 GB in Status Bar.
    Switching to View as List shows 981 items in Status Bar.
    It’s possible they are all purchases but at least a dozen I don’t recall purchasing and wouldn’t initially have any interest in based on the artists. Some are full albums, some only a single track, although Albums is selected in the Library source section.
    Which all reminds me, what the hey is “downloaded” music? from where to where? When i connect my iDevices to sync, the music is… downloaded to the device from the Mac. Or do they mean downloaded from iTunes? if so why isn’t it called ‘purchased’ (even though some may have not cost anything).
    Anyway, bottom line is, if you think something is still fouled up or if it is safe to start dragging my music etc back into the iTunes folder?

    • Right. View > All Music is the music in the cloud. So that’s either purchased music, or music in an iCloud Music Library.

  38. PS–I just looked at the iTunes Media > Podcasts folder (the new one generated after moving everything out) and there is one episode of one podcast in there, but it doesn’t show in the Podcasts in iTunes itself. It is one of a few I subscribe to but… I removed everything from iTunes Media folder the other day. How did this one get there? if iTunes put it there why wouldn’t it show in iTunes itself?
    Arg arg arg. I just want to purge this thing.
    Maybe I need to go through this whole process again but first sign out of my account in itunes and disconnect from the internet…

  39. Can iTunes 12 build a consolidated Media Folder after the fact?
    Hello, this question is a little different than it sounds. I am current on iTunes 12.6, and have just moved all my Music & iTunes DB’s onto a Synology NAS drive. However when I did this I DID NOT check the advanced preferences: Keep Media folder organized, nor Copy files to iTunes Media folder when adding to library. As a result, iTunes put nothing in the iTunes Media Folder location specified in Advanced preferences. But I did follow your advice and checked the box to share iTunes Library XML with other locations. I built the Synology version of iTunes using the iTunes Media Folder from my old computer as input via Add Folder to iTunes Library to an empty version of iTunes I created new on Synology.

    I just completed a fair amount of rationalization, finding missing songs and albums and letting iTunes know where the music & artwork for each album is located (same folder as the album music). So instead of having a complete set of organized and rationalized media within the iTunes Media folder I guess it’s all buried within an iTunes DB somewhere. I have about 500 artists and my old media folder is about 150gb, so not an easy or quick process to rebuild and rationalize everything a second time.

    Is there a way to have iTunes completely build a complete version of the iTunes media folder from scratch since it has all the information in its databases with a pointer to the physical location of every song, and each bit of artwork. For instance, if I now changed the advanced preferences and checked those boxes would iTunes only manage and copy music for any new music I added from this point forward or would/could it build the entire iTunes Media Folder ?

    Thank you! Fred

    • File > Library > Organize Library, then Consolidate Files should move the files to the correct location.

      However, if you’ve moved files after moving the folders onto the NAS, it might not find everything, and those files you moved may be orphaned.

      • Kirk, thank you for the quick reply & yes the good news is that all the files are in their original locations, none of the original files have been moved, or modified in any way so hopefully no orphans.

        Two points of clarification, please:
        1) Should I change the Advanced Preferences to select: ‘Keep Media Folder organized’ & ‘Copy files to Media Folder when adding’ prior to: File > Library > Organize Library, then Consolidate Files?
        2) After Consolidate Files is complete – the newly created Media Folder will then contain all data pointed to by the various iTunes Library data bases and Playlists. Meaning, I can then remove the original files used prior to consolidation (after validating the consolidate did indeed work correctly and completely – in case I need to do the consolidate a second or even third time)?

        Thanks again.

        • Yes, you should definitely set those options so iTunes moves your files to the correct folders. I don’t think you’d need to do it more than once, but do back everything up just in case something doesn’t get moved.

  40. Followed this How-To article and it appeared to work OK, except, I now have 2 of every Playlist in iTunes – both Custom Playlists and iTunes own automatic Playlists, e.g. Recently Added, Recently Played, My Top Rated, etc…! What’s happened there???

    • It sounds like you didn’t start with a completely empty library before we building. You can just delete all the duplicate playlists.

  41. Am I the only one who cares about the “date added” information? For me, my library becomes like a history of my life going back 15 years, sorting by date added. I would REALLY hate to lose that data.

    From what I’ve been able to figure out, the date added info is readable in AppleScript, but it’s not writeable. So Doug’s AppleScripts is not likely to have a solution soon.

    I’m hoping that there may be some kind of kludge solution.


  42. Am I the only one concerned about preserving date added information? Normally, that gets nuked anytime you rebuild the library from XML. Any ideas?

    • I find it a nice to have but I won’t be too broken up if I lose it. More important that I can access my entire library and play counts, last played, ratings etc maintained.

  43. Wow! This is a very popular (and very helpful) blog. Thanks for this! Unfortunately, I’m having a slight problem. I grabbed an iTunes Library file (no XML because I didn’t have that option turned on before iTunes crashed on me and created the “damaged” iTunes Library file) from an online backup and am trying to import it, but iTunes keeps saying: The file “iTunes Library.itl” cannot be imported because it does not appear to be a valid exported file. Any thoughts on how to deal with this situation would be greatly appreciated! It’s probably worth noting that my iTunes Music folder is 800GB or so. Thanks again for the helpful blog (and amazing response to commenters as well)!

  44. Hi Kirk, i made problems for my self. Before the problem i had i tunes playlists on left column. itunes library was on my computer and mp3 files located on external drive. mp3’s was dragged and dropped to playlists and there was no copys made by itunes on itunes media/audio folder.

    Now i changed new external drive, moved my files and itunes can’t locate the mp3’s. I have copy of previous itunes folder, containing my playlists and all, but when i get the file info, path is wrong. There is no help to change path from itunes advanced settings window and update the library, or try to make itunes make copy of the playlist files, because it’s not working. I can’t rebuild the library.

    Is there some work around to make it possible to itunes scan new external hdd and find the files and they path. My mp’s are many different folders, sorted by example: computer 1/mp3/artist name/record title
    computer 2/mp3/artist name/record title
    computer 3/mp3/artist name/record title

  45. Hi Kirk

    I had my iTunes on an external drive called “BigMo” and iTunes->Preferences->Advanced->iTunes Media Folder Location pointed to /Volumes/BigMo/iTunes … in that directory I had my .xml and .itl files. I have a lot of ripped CDs and I also subscribe to Apple Music.

    I moved the disk to a new computer, set my preferences the same but things got confused with all of my ripped files “gone” — iTunes wanted to download them. So I followed your instructions and waited for iTunes to chug along and it finally finished. I’m very happy with the results but, of course, there is a catch.

    My iTunes Library.itl and some other files now live in ~/Music/iTunes. I suppose that is ok but I’d rather have those files on the external hard drive. I’ve tried resetting my Media Folder Location to the default and then change it back to the original path but those files still want to live in ~/Music/iTunes … Is there a simple way to change it so those files will be on the external hard drive?

    • Why would you rather have them on the external drive? It’s certainly possible to do that – quit iTunes, move the files, then launch iTunes by double-clicking the .itl file – I’ve found that this can cause problems.

      • Thank you for the reply…

        Well, this may be a lame reason but I have a very old memory of setting up my library with the music files in one place and the xml file (back then) in another place and it proved to be awful… but I can’t remember what happened.

        One small nit is some of the data is such as Album Artwork is on the laptop. The iTunes directory on the laptop right now consumes 404M. I guess… today that isn’t significant.

        I’ll keep it like it is and see how it goes.

        Thank you again for the web page and the followup.

  46. Many thanks, Kirk. I had many duplicate songs that could not be deleted nor played (really weird), and your method was the only solution that fixed it. (iTunes on the PC)

  47. Kirk, I thought this was exactly the answer to my problem. I have many songs and artists in my iTunes folder on my hard drive that do not appear in my iTunes library when I open it, so I thought if I rebuild the library that would do the trick. It still may, but here’s the problem: in my iTunes folder, there is an iTunes Library.itl file, but not an iTunes Library.xml file. What should I do?

  48. Hey Kirk back to older Threads of yours regarding ITunes stealing/deleting my music. I have noticed little by little MANY OF my LOCAL MUSIC LIBRARY.. The Artists Folders/Album/Tracks are coming up Blank little by little NO TRACKS. Many of them Show an exclamation on iTunes. So if they are not in iTunes and Not my Local Library…where are they going?

  49. Right when I was about to pull my hair out after uttering every swear word I try to avoid….BAM! I found your article. Thank you so much!!

  50. Thank you!! I was struggling with the songs cutting off before the end issue, and mysterious duplicates … rebuilding the library seems to have fixed these. Is this a “relying on a gigantic database stored and used in a fashion that was never intended” issue?

  51. Thanks Kirk. This article helped but a I have a couple of questions. First – background.
    – I have an Apple Music subscription
    – I moved my iTunes folder to a NAS a few months ago.
    – I redirected iTunes on my iMac to the new location for new adds.
    – I installed iTunes on a NUC PC I have in my office and pointed it to the same place. It gradually began to populate to satisfaction.
    – At this point I began moving music (mostly mps) from a failing hard drive from my old pc that I was able to fire up in an enclosure. The drive has some issues and so I had to restart it a number of times before the Windows 10 NUC would recognize it as anything but a RAW drive needing formatting. I knew it was not. Eventually I gained access to those files on the NUC. I am using the windows pc for this because the failing drive was formatted as NTFS.
    – I moved all of the mp3s off this drive and into the music file on the NAS. Barely made it as the drive failing drive started pulling its old tricks near the end,
    – At this time I began ripping my cd collection to the same file via an external drive I connected to my Mac. I am ripping in ALAC.
    – All was going well until I got somewhere into the G’s in the alphabet. At this point I started getting funky messages about a file that could not be saved or some such. A few other mystery errors as well. But the files were still ripping to the drive and showing up in iTunes so I kept going.
    – Next I see this error: ‘iTunes can’t verify the identity of the server “”. I don’t know what this is. It is not the name of my NAS server.
    – Subsequently I get another error, this time ‘The iTunes Library file cannot be saved. An unknown error occurred (13010)’. Got this same error several times. But I was still able to rip cds to NAS that were showing up in iTunes.
    – At this time I also noticed about 20 iTunes tmp files now showing up. I let them stay for a bit and then trashed them.
    – another cd or two ripped and I got an error about corrupted itl file being saved as damaged. I tried to use an older itl file (only a few hours older) but things were getting weird. Now only purchased music was showing in library.
    At this time … I implemented the Kirk Plan.
    First time my library showed three tracks and spinning beachball for 8+ hours. I quit that process and tried it again. This time the library began populating. Over time and on completion … it looked like I was most of the way back … but three issues.
    1. Podcasts were showing up as tracks in albums in music. And it had bypassed my setup to pull in only most recent episode and instead pulled in all of them. While this is a PIA … I can get rid of this.
    2. All my playlists were duplicated…except that the duplicate playlist contained no tracks.
    3. I have ripped albums and tracks no longer showing in iTunes. They are still physically on the NAS in the same spot and if iTunes was scanning those files I would think they should have been picked up … but they were now. So far . the ones I am noticing seem to be the most recently ripped / added to library but it will require a closer look.
    Any thoughts on causes or remedies on any of these items. Not knowing bothers me. Its hard for me to just chalk things like this up to general funkiness.

    • Well, that’s a lot…

      First, it’s not uncommon for iTunes to not get along with NASes. That server might have something to do with the NAS software. It resolves to this: Not sure if your NAS is doing something with podcasts.

      Rebuilding a library on a NAS can take a long time. I think iTunes reads the files entirely to look for tags, even though it should only have to read parts of the files.

      As for 1, I don’t know; I hear that every now and then. 2, duplicate playlists, that’s not uncommon. I’ve heard from people who have thousands of playlists. And 3, you might need to re-add them, but it’s possible that your XML file was created before you added them to the library. Did you check the date it was modified before you imported it?

      But I don’t trust iTunes with a NAS any more. I’ve tried it a few times, and there have always been problems.

  52. Thanks Kirk, and thanks also to all your contributors in this thread. I now realise, after a couple of days scratching my head to no avail, that I should have read the thread backwards. This is the key entry for me:

    “But I don’t trust iTunes with a NAS any more.”

    However, I’m still puzzled. Why should the .xml file be any more reliable than the .itl file as a base for rebuilding the database? After all, aren’t they both the same core data written out by iTunes in different formats?

    FWIW my issue has arisen just recently where using a NAS (WD MyCloud) for the media files for iTunes has caused the NAS intermittently to “disappear” from the network. It happens on both Macs which use the NAS. It has worked reliably for over a year but a couple of weeks ago it started dropping the network connection so “something” changed – a new version of iTunes, an OS update, …?

    Looks as if I will have to go back to an attached hard drive.

    • The .itl file is more susceptible to corruption. It’s written every time there is a change in iTunes. The XML file, which is just a plain text file, isn’t written as often.

      As for the NAS, you might want to listen to this episode of my music podcast The Next Track.

      We discuss the problems with a NAS, and talk about an AppleScript that can improve its use with iTunes. But I won’t use a NAS any more; there are just too many problems.

  53. Hell Kirk I have 2 ipod classics I couldn’t sync them So I called apple and the techs gave me the wrong info and it wiped my entire library out, but I backed it up it just won’t allow me to sync with my current library, if I load iTunes fresh on a new hard drive and put my old library in will it let me sync. or is there a away too clone my ipod with my wifes being they were the same before the chaos

    • You should be able to restore the iPod with iTunes, then sync your current library. That’s the best way when things go this wrong.

  54. Hey Kirk. Thank you as well. I am not able to import the playlist because it starts and then I get an error message, cannot locate the songs. I saved two library files so i have a 20,000 kb file in two locations.

  55. Hi Kirk,

    I had this weird problem long time ago where iTunes would skip mp3 files before the end (it didn’t seem to affect AAC files). I solved it following this great guide. Now I’m using iTunes on El Capitan 10.11.6 and my songs play just fine.

    HOWEVER, I’m seeing this bug persist in my iPod Video (5.5G), which is super weird as I’ve just restored it recently with iTunes. It’s the same nightmare I used to experience a few months back — mp3 files skipping before the end, only that in my iPod.

    I even ran a test and converted an album which would present this problem on my iPod. I made an AAC version of it, sync it and guess what… it plays just fine. On my iPod.

    Just in case, I have the Share iTunes Library XML with other applications option activated in iTunes.

    Do you think there might be a reasonable explanation as to why this problem persists on my iPod, even though it seems to be solved in iTunes on my Mac?

    • There are some weird things that can happen in MP3 files that can cause that to happen. As you say, converting it works fine, but I don’t know any other solution to fix it.

      • Thanks for your quick reply.

        Yeah, I was hoping I could find another solution and leaving the AAC option as a last resort. Converting files when we are talking about hundreds if not thousands is not a very practical solution, not to mention I’d have to do the same every time I add a new album to my library. I guess I’ll have to get use to it =(

  56. After reading all the post, i’m still confuse on how to go about my problem. i accidently highlighted the songs in my itunes and gave them the same artist name, album name, artist album name and composer name. Is there a means by which this can be fixed. I have just my macbook pro and no backup

  57. Got an iTunes Library (Damaged). Could not find a recent iTunes Music Library.xml. Until I looked inside an #Recycle folder on the same level as the iTunes folder. Lots of numbered xml’s there, the most recent one was up-to-date and fixed my problem as described above.

  58. Hi there,
    I backed up my music folder onto an external hard drive (using an imac).
    I deleted everything out of the music folder after that.
    Forgetting that it was needed for my itunes.
    Opened my itunes and it asked for the music files.
    I copied the files back to my imac and selected the xml file.
    It gave me playlists only up till 2015.
    All the rest, made over 3yrs of DJing are gone.
    I found this site did the copy the xml and the itl to the desktop thing as you’ve said.
    It’s now just duplicated the same playlists from 2015 inside my itunes.
    So now there’s an insane amount of the same stuff that was there before!

    Please, any help would be immensely appreciated.
    I noticed that my iTunes Music Library.xml file date was from October 2015.
    Why is that?

    Cheers in advance.

    • As I point out, since iTunes 12.2, the XML file is only saved if you expressly tell iTunes to save it. So there’s nothing you can do. Unless you have Time Machine backups of the .itl file, in which case you can go back until you find a file that works. Sorry, but that’s the way iTunes works now.

  59. Hi Kirk, I had some problems with my internal HD, 8 months ago, prepared an external disk (4TB, Thunderbolt) which is my boot drive now, with everything on it. My version of iTunes is, running on iMac with High Sierra.
    Now, for some time, I experience problems with the indication of ‘times played’ and ‘last played’ of tracks, some tracks do update and some do not after being played, I cannot see the difference between tracks that do the update and the ones not updating.
    Any clues? Thanks in advance.

  60. All I want to do is have iTunes recognize all the music on my external hd. There are no playlists or anything. I’ve never used iTunes on this laptop, so I copied it over to the external I use with this machine.

    • Drop the folder containing the music files on the iTunes window. Make sure you set the iTunes media folder location to the external drive that contains your music.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.