Currently Being ModeratedApr 2, 2013 1:31 AM (in response to geogan)
Empty/corrupt library after upgrade/crash
Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. Note that in iTunes 11 an "empty" library may show your past purchases with links to stream or download them.
In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
Alternatively, depending on exactly when and why the library went missing, there may be a more recent .tmp file in the main iTunes folder that can be copied and renamed as iTunes Library.itl to restore the library to an earlier state. Look for a recent .tmp file that is similar in size to the .itl files in the Previous iTunes Libraries folder. If it has happened repeatedly you may want the earliest such file generated since the last iTunes upgrade.
If applicable, see iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
When you get it all working make a backup!
Should you be in the unfortunate position where you are no longer able to access your original library, or a backup of it, then see Recover your iTunes library from your iPod or iOS device.
I've noticed more of these missing library posts of late and a common factor to most since I started asking is AVG Anti-Virus. It seems in some cases it might be at least part of the reason why the library file disappears. Try excluding the iTunes folder from any AV scanning process.
Currently Being ModeratedApr 2, 2013 3:40 AM (in response to turingtest2)
I just checked the iTunes folder and there appears to be many tmp files.
There are 6 tmp files dated today (total 16Mb) and 25 tmp files dated yesterday (total 72Mb). They are all about 5Mb in size while the iTunes Library.itl file is only 925Kb.
Is iTunes supposed to produce so many tmp files in one day?
In the "Previous iTunes Libraries" folder there are no new files for this year at all. Last one is "iTunes Library 2012-09-29.itl".
I can't and don't really want to replace the current one with one of these because I have no idea which one to use...
Currently Being ModeratedApr 2, 2013 4:30 AM (in response to geogan)
iTunes makes a temporary copy of each database file as it updates them, then delete the originals and renames the new copy to replace it. The temporary files you can see result from the process being disturbed. How big is iTunes Library 2012-09-29.itl? Is there a temporary file of a similar size dated around the last time your library was working properly? The earliest one that is within the timeframe is the most likely to work. Otherwise, unless you have some other backup, you will just have to go back to the last known good .itl from the Previous iTunes Libraries folder. You will lose recent ratings, playcounts and recently added playlists, but any media added in the meantime can be imported by adding the media folder to the library and at least your iPhone will be able to sync with a restored version of your library. If you're really keen not to lose the ratings & playcounts my script SyncStats might help
Currently Being ModeratedApr 2, 2013 6:40 AM (in response to turingtest2)
The iTunes Library 2012-09-29.itl is only 900k so no way I'm going back to that one.
I still don't understand... are they backups of the iTunes Library.itl file? If so why are the backups nearly 5Mb while the live iTunes Library.itl file is only 923k??? And why would it create 25 .tmp files yesterday of various sizes (actually all either 1Mb or 5Mb) when I only connected the phone to computer once to sync and charge up???
The next previous .tmp files are all from 27th and there are 117 of them (again all either 1Mb or 5Mb).
Does the number of tmp files per day indicate there is something seriously wrong with the iTunes setup? ie. it is trying to do something and failing?
So you think one of those .tmp files from yesterday would contain my new playlist? I don't understand though... does that mean it failed to copy the newest iTunes library and then gave up and restored the one from 2012 (considering they are similar size)??
There are currently 702 tmp files in my iTunes folder taking 33.4Gb of space! Seems to begin 1st December 2012.
Currently Being ModeratedApr 2, 2013 6:46 AM (in response to geogan)
How many songs are (or should be) in your library? The library file is an index to these and also holds your playlists, it isn't necessarily that large. The .xml file is larger in comparison. For me iTunes Library Genius.itdb is somewhere between the two and iTunes Library Extras the smallest. As far as I can tell each of these files gets updated via the .tmp file mechanism. Each .tmp file you see may be a complete or partial copy of one the database files.
Currently Being ModeratedApr 2, 2013 11:52 AM (in response to turingtest2)
There's 3131 individual tracks - 19.65Gb
But are you saying they shouldn't be building up tmp files like that? That it should delete the tmp files as soon as it creates them?
I might try moving them all out somewhere else and renaming a 5Mb latest one. But there's loads for same day and same time creation????
Currently Being ModeratedApr 2, 2013 1:11 PM (in response to geogan)
The library records the path to each file, a local copy of the tag data and playlist membership, in a custom SQL database from what I can gather. It should be quite compact. The XML is most of the same data in a plain text form, and typically much larger.
Yep, they're supposed to appear briefly, the original deleted and then the .tmp renamed. If iTunes is functioning normally the only time you see one is if you happen to be watching for them to flick in and out of existence (though my home PC is so slow and I can actually refresh the view and see the size change) or if the computer crashes mid flow and they are there when you reboot. iTunes does a bit of fault tolerance by using the hidden sentinel file to note when it is updating files so it will do an integrity check in certain circumstances, but if your library is in the normal location of <User's Music>\iTunes and iTunes Library.itl is missing on startup then iTunes behaves as if it has just been installed. No error messages given.
AVG seems to be linked to a lot of these, though I guess another mechanism could be in play. That said I'd try disabling it, or whatever AV you use, while you're trying to get sorted, at least until you've found and backed up a good file.
Currently Being ModeratedApr 2, 2013 1:54 PM (in response to geogan)
Exactly the same thing happened to me this evening, but I managed to get it all back. Have a look at all the temporary files that are now sat in your iTunes folder. I wondered if these might have been created by some error with the libraries. Here's what I did.
Delete all your music in iTunes, but remember to 'Keep Files'
Delete the 'iTunes Library.itl' file. Also delete 'iTunes Music Library.itl' if that's also there.
Look at the times that the temporary files were created. Choose the most recent, but at a time when you had your full library available. There will be more recent ones that will just have the new 'minimalist' library in them!
Rename it 'iTunes Library.itl'. It will warn you that changing a file type can do all sorts of nasty stuff, just confirm you still want to do it.
Re-open iTunes, et voila, music SHOULD be back.
Probably worth backing up at this point if it worked
Currently Being ModeratedApr 2, 2013 9:26 PM (in response to funkyphill)
FunkyPhill, you just saved me from flipping millions of tables. All my playlistsfor the second time in the week had disappeared off itunes. I recreated it the first time it disappeared, slightly ****** but I kinda needed to clean the playlists as it was a mess. But when it disappeared again today, I couldn't redo all that work recreating from scratch again.
I remember seeing itunes had a "Previous itunes Libraries" folder on some versions of itunes but not on my computer. Your steps to fixing the problem were perfect. I never knew itunes just kept the old playlists and renamed them to "iT 1.tpm", "iT 2.tpm" etc. I found my iT 13.tpm was 419kb while the next tmp file was "iT 14.tmp" at 5kb. Following your steps on deleting and renaming that 13th tmp file to iTunes Library.itl fixed everything. THANK YOU.
When I reread Turingtest2 post after fixing, it now kinda makes sence what he was saying so credit to him too.
Currently Being ModeratedApr 5, 2013 12:13 PM (in response to turingtest2)
Restored two tmp files from 27th of last month. Found out (using binary editor) the 1mb file is binary and the 5mb file is xml plaintext version. I also deleted the sentinal file. Then started iTunes and my missing playlist was now there. Thanks for all the help!
Currently Being ModeratedAug 4, 2013 11:25 AM (in response to geogan)
This problem with edits to playlists disappearing has reappeared again.
I edited the only playlist I use on my phone a few days ago (sync to this one only) and my new editied playlist appeared on phone and was working fine for two days. Then today I noticed that the playlist had reverted back to the way it was before I did any edits and this was now on my phone and also in iTunes.
I had to restore a .tmp file from 2 days ago in order to get the edited playlist back.
Also iTunes is still creating huge numbers of .tmp files (pairs of 1mb and 5mb binary/XML). On the day I edited it created 51 pairs of them (102 files). Appears to be continually making them as long as iPhone is connected.
There are 499 of them in temp folder again since last cleanout (dated 27 march to 4th august)
ps. I don't use AVG, I use Avast! Antivirus