How to update the play count on iTunes & iPod

From software to hardware, breakthough to disaster, it all belongs here!

Moderator: CricketMX Forum Moderators

Post Reply
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

***To skip the intro, and see how I updated the play counts, scroll about 50 lines down***

Recently I went through the trauma of hard-drive failure, but fortunately when I realised something wasn't quite right, I backed up my files, including all of my music, to another hard-drive.

In iTunes, I exported the playlist as a .xml file, before proceeding to clear my library. Prior to the failure, all of the music & video files for iTunes were located either in E:/iTunes Files/iTunes Music/ or C:/Documents and Settings/Owner/My Documents/My Music/iTunes/iTunes Music/

Seeing E:/ went belly up, I decided to put everything (including the files in C:/) into F:/iTunes/

This is what I did, to transfer the files and update the play count
  1. Open the playlist backup file (In my case, Playlist.xml file) in Notepad++ (you can also use Notepad, Wordpad or any other text editor).
  2. Use the Find and Replace function to replace all instances of both E:/iTunes Files/iTunes Music/ and C:/Documents and Settings/Owner/My Documents/My Music/iTunes/iTunes Music/ and turn it into F:/iTunes/
  3. Save the playlist backup file under a different filename, I chose Playlist_new.xml
  4. In iTunes, remove everything. Delete all playlists and libraries, so it is essentially a blank canvas.
  5. Go to File -> Import in iTunes, and restore the new backup file (Playlist_new.xml)
At this point, you will realise that everything has been restored correctly. That is, except for the play count and last played dates. Apple has not made it easy to update the playcount and last played dates, and why, I do not know. I feel they (play count in particular) are the most important stats for your iPod, how else do you sort your favourites, besides giving it a star rating? Smart Playlists make it easy to sort your favourites, for instance, you might have a playlist with your top 100 most played songs, sorted by play count.

HOW TO UPDATE THE PLAY COUNT

To update the play count, this was my procedure (unfortunately, I don't know how to update last played... which doesn't really matter anyway, as it will update whenever you next play the particular song).
  1. Open a new window of Notepad, and paste the following code:

    Code: Select all

    var iTunesApp = WScript.CreateObject("iTunes.Application");
    var track = iTunesApp.CurrentTrack;
    track.PlayedCount = 100;
  2. Save this as update.js into My Documents.
This is a fantastic little script which I found at ottodestruct.com. Without it, I would have been left to play the end of each song however many times to correct the play count.

Now, to update each songs play count:
  1. Open Playlist.xml in Notepad++ again. As you saved your changes to Playlist_new.xml, Playlist.xml should remain unchanged.
  2. Open iTunes, and go in to your Music library (the very first playlist under the word "Library" on the left of screen)
  3. Sort the songs by Artist (you can order it in any way you want, but I find Artist is the simplest)
  4. Play the very first song, by double clicking it.
  5. Go back to Playlist.xml, and using the Ctrl+F search function, search for the name of the song you are playing. Then look for this:

    Code: Select all

    <key>Play Count</key>
  6. To the right of that, you should see:

    Code: Select all

    <integer>43</integer>
    Whatever the number between the <integer> tags is, is the play count. In the case of that song, it was 43.
  7. Go to your update.js file, which should still be open in Notepad.
  8. Change track.PlayedCount = 100; to track.PlayedCount = 43; ..... it is very important that the line ends with a semi-colon (;), so ONLY change the actual number, nothing else.
  9. Save the file by using Ctrl+S (this is quicker than File -> Save)
  10. Double click the update.js file in your My Documents folder (leave My Documents open in the background to make this process quicker)
  11. Go back to iTunes, and you will see the file has been updated. This might take 5 or so seconds to update, but I found it to be almost instant in most cases.
This must be repeated for every file. In summary, what must be repeated:
  • Play song you wish to update play count of
  • Search for that song name in your original .xml file, and note the number of plays it had
  • Update the last line of update.js and save the file
  • Double click update.js to run the file
  • Once the play count has updated, double click to play the next song in the list, and repeat the process.
I hope someone finds this useful. Obviously I can't guarantee it will work for everyone, but it certainly worked for me.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
nesman
Miracle Worker
Miracle Worker
Posts: 1453
Joined: Thu Jan 15, 2004 8:17 am
Contact:

That's pretty cool. I've been on a data-loss-prevention kick lately, so this kind of hits home. Too bad it's not easy to automate this, huh. :/
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

It might be possible to automate! I have no idea how though, you would need a script to automatically play the song, search the original .xml file for the old play count, update update.js, and then run the file before repeating the process.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

If you want to update the play count for a song in iTunes, but you are using Mac OS X, you can use what is called an AppleScript.

Download the script from http://dougscripts.com/itunes/scripts/s ... tskipcount

I have tested this on Leopard and it works very nicely. Much easier than the Windows method. It will appear in your menu bars after installation (a matter of dragging the program into an installation window - it is quite clear explained in the download).
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
Post Reply