You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is there any way to edit an itunes library.itl file?

Recently I lost five years or so worth of play counts for a few hundred songs as the result of what I presume is a bug (Which has been discussed elsewhere on the forum). What I'd like to be able to do is open my most recent itunes library (.itl) file and edit it side by side with an old backup from November. The goal would be to manually add the old playcounts for the songs that subquently got reset to zero to the new library without reverting the intact playcounts to November. Ideally, I'd even add the playcounts from November for the zeroed out songs to any playcounts they may have generated since being zeroed.


Anyhow, I tried opening up the .tl file in a text editor and got gibberish. Is there any application out there I can use to read and edit these files in a way that'll allow me to edit playcounts for various songs?

Windows Vista

Posted on Dec 16, 2012 10:14 PM

Reply
11 replies

Dec 17, 2012 5:25 AM in response to CharmCityCrab

There are no external editors for .itl files. It is a closed format. It is possible to edit the XML file and do a partial rebuild using it, but from experience I would suggest the export and reimport/combining of selected values via script is going to be the best approach. Sorry I can't get to it any quicker but I will make good on my offer in the other thread.


tt2

Dec 18, 2012 5:55 PM in response to CharmCityCrab

Nearly there. The export process is all ready and easily extendible for any properties others might want to export and manipulate. The mechanism to use the same script for import is also tested which saves having to edit two separate scripts in parallel when it needs a tweak. I've got as far as reading in the data but now I need to make sure it's being applied only when it is relevant to do so, to the correct track. Not long now...


tt2

Dec 19, 2012 6:28 AM in response to CharmCityCrab

The script is essentially done. I'm currently teasing out the details of how to roll forward Last Played or Last Skipped, or rather how not to update them when they should remain the same. The iTunes script interface has some odd issues with summertime/time zone corrections that I can't quite nail down.


If you want to bring forward tag-based properties that have been "corrected" and saved back to the tag, e.g. Genre, then the following steps would work.

  1. Close iTunes.
  2. Temporarily rename the media folder to say iTunes Media (Temp) so that iTunes cannot access the files inside during the export phase.
  3. Backup the current iTunes Library.itl database (move and/or rename it).
  4. Restore an older database which is an earlier version of the same library.
  5. Run iTunes. Select the playlist or tracks you want to save data for and run the script to export the data. This creates a plain text file in the main iTunes folder called iTunes Metadata.txt.
  6. Close iTunes. Put a copy of the current library database back in place (use a copy in case of problems) and restore the media folder name.
  7. Run iTunes. Drag & drop the archived data onto the script to import the saved properties into the active library.


If you only want to bring forward stats that aren't stored in tags, ratings, playcounts etc. then you can skip the renaming of the media folder. If, as has been suggested, iTunes 11.0.1.12 has fixed the bug that caused the loss of data you can do this without needing to downgrade iTunes first. If that isn't the case then you would need to downgrade to 10,70.21 before restoring the old library and doing the export.


As ever a full and complete backup is recommended before you start. I would also suggest you test the process with the stats for a single album before letting it loose on your whole library.


Can you let me know exactly which properties you'd like to try to roll forward? I will customize before uploading so that just that data is exported. As suggested earlier I can make plays add together if the current value is less than the historic one. I should be able to bring forward the last played date if the current value is empty (or older for some weird reason). Similarly for skips. Could also drag genres and pretty much anything else forward that you want with the exceptions of Date Added and Date Modified if using the scheme above.


An alternative use for the script would be to export data from the current library, manipulate say in Excel, then import the corrections.


tt2

Dec 19, 2012 9:03 AM in response to turingtest2

"Can you let me know exactly which properties you'd like to try to roll forward?"

At this point, I am only looking to roll forward play counts for songs affected by the zeroing bug, adding them together with current play counts for those songs if possible (As some are now non-zero, having been played one or more times after the data loss), identifying them by any tracks that have lower play counts in the backup library file than in the current one.


All tracks that were not previously zeroed would be left as-is in the current library, with nothing brought forward from the old library. The previously zeroed tracks that would be modified would ideally be untouched other than play count (Last played was not affected by the zeroing bug, so we'd keep the last played data from the current library file intact for all tracks if possible).


This would give me play counts reflecting everything prior to November 29 plus everything after the tracks were zeroed a couple weeks later added together, and leave all other songs alone with continious playcounts they have accumulated for the last few years right up to the present. Last played would remain as it is at this second in the current library for all songs.


Fortunately, I've been able to musually make corrections to genres, albums, track numbers, etc.- at least enough so that I'm comfortable being able to "catch" any stray ones and make changes in the future as necessary. Other folks may need a script for that purpose, though, if they had more genre categories than me or didn't catch what was happening quickly enough.


So, "play count for previously zeroed songs only" would be what I'd personally be going for.


Sounds like the script is almost ready. I'm excited about getting things as close to corrected as we're going to get and being able to move forward.

Dec 19, 2012 12:31 PM in response to CharmCityCrab

OK, I've uploaded the ExportImport script for you. Right-click on the link and "download" or "save as" to the location of your choice. The logic for bringing forward playcounts is that if the archived count is higher than the current count then this is probably a track that got zeroed so the archived count and current count will be added together. If the current count is higher or the same nothing will be changed. For other users tweaking a few comments would, for example, restore the old values in preference to the current ones. (Ask and I'll be happy to explain.)


Make a small export file for a sample album you know has been affected and test the import phase just to make sure it is doing what you want. If all is good you can move on to do the whole thing.


Here is a sample output from the export so anyone else interested in this discussion can see what it looks like:


<#>iTunes Metadata - Exported 19/12/2012 20:03:58


<ID>E5C69360-306A28AF

<#>AC-DC\AC-DC Live\1 Thunderstruck

<Plays>12


<ID>7C1D487C-3414298C

<#>AC-DC\AC-DC Live\2 Shoot To Thrill

<Plays>12


<ID>0DCF32CE-1079174E

<#>AC-DC\AC-DC Live\3 Back In Black

<Plays>15


<ID>E9C05A9E-2EB1B8B2

<#>AC-DC\AC-DC Live\4 Who Made Who?

<Plays>11



<ID>CC455E19-90C6FECC

<#>AC-DC\AC-DC Live\5 Heatseeker

<Plays>10


<ID>13742BA4-F1EF0ECF

<#>AC-DC\AC-DC Live\6 The Jack

<Plays>11


<ID>460F0EFF-9091C5B3

<#>AC-DC\AC-DC Live\7 Moneytalks

<Plays>10


The <ID> identifies the track the data was exported from, a comment below helps us humans see which track it refers to, then comes the play count, and potentially any other data that someone wants to export.


Good luck. Did I tell you to backup already? 😉


tt2

Dec 19, 2012 1:08 PM in response to turingtest2

Thanks!


I think there may be an error in the address of the link URL or an error that took place in the upload process, though. When I click "save as", my browser is returing "No file" as a response. When I directly access the link, the server hosting your website returns "The system can not find the file specified"


I checked a different script on the site, and clicking "save as" does return a file, and left clicking returns the text of that particular script.

Dec 19, 2012 5:39 PM in response to CharmCityCrab

Alright, now I trying it with smaller playlists and not getting the error message (It only appears when I attempt to process all of my songs), however, on the smaller playlists I get a text file labeled "iTunes Metadata" that lists things in a format like:


"<ID>52B480DC-62ABFD13

<#>Weezer\Weezer (Green Album)\10 O Girlfriend

<Plays>0"


So it's not actually changing the play count data, probably due to user error on my part.


What do I need to do in order to get the results I want? I assume there's some way I need to make this interact with the backup files, versus just having it interact with my current music. I'm essentially just double clicking on it and having it launch itunes, or having itunes open to a playlist created for this purpose and then running the script.

Dec 19, 2012 8:35 PM in response to turingtest2

Alright, figured it out! I feel kind of stupid not realizing this immediately.


For those who might be similarly puzzled, the key is to replace your current itunes library with your old one by renaming the library files. Then highlight the songs, run the script, and save the text file that results. Sometimes the script wouldn't run, and I had to try a different number of files and running it again, and wound up dividing the library up into like 7 different text files of output.


Then, swap back in your new library by renaming the library files, and drag the text files one at a time into the script icon itself. Some didn't work the first try or two and I had to repeat, but they worked eventually.


Anyhow, I think I've got things now. 🙂


Once one works around the error messages and such, the script seems to work exactly as described.


Thank you so much for writing this script! It was very helpful. I feel like I'm finally back to the point where I can start just enjoying my music again with my playcounts more or less intact (albeit with a couple missing weeks of plays, but there was no way around that- there was just no record there to restore). My music collection is saved!


Eventually I'll have to deal with Apple's decisions regarding genre editing and having had to cut my itunes off from Apple's servers, delete genius, etc., and figure out what I want to do. But for the time being, I feel like I've got everything back to normal (minus points of contact and features related to Apple's servers and store), and can relax for a while. Maybe Apple will get it's act together and rollback some of it's decisions. If not, I've got good playcounts now that I can move to other software in the long run if need be.


Thanks again for your help!

Is there any way to edit an itunes library.itl file?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.