22 October 2012

MetaData Transfer from WMP11 to Foobar2000

I've been acclimatizing to a new computer recently and because of this, I've been looking into way to transfer my music library over to the new system. Unfortunately, I've been using WMP11 for the last 4 years, so it ended up being more difficult than I expected. I wouldn't recommend attempting this unless you have programming skills or are prepared to spend some time formatting and playing around with data fields.

The two main metadata values I was interested in were %play_count% and %added%. This metadata is very valuable and I use it daily to sort and display my songs in the correct order. Unfortunately, they are both stored in a proprietary WMP11 database format that is not easily accessible. WMP also doesn't offer to way to transfer this metadata. So to extract what I wanted, I used a very useful backup and restoration tool created by Dale Preston known as MetaData Backup (website now defunct, use https://sourceforge.net/projects/metadatabackup/). This tool extracts the metadata to an XML file, where it can then be accessed as required.

If you only want to transfer this data to another instance of WMP, this tool can also be used to perform a metadata restoration quite easily. However, not all fields can be restored (some are read-only) and I had had enough of WMP running wild with my metadata, so I decided to transfer everything to another media player called Foobar2000. Foobar2000 offers powerful customization tools as well as the ability to import and export playback statistics using a component called foo_playcount. It allows the user total control of valuable metadata as well as the ability to perform a complete backup and restoration at any time (or in another 4 years when I get a new computer).

First, the metadata held in the .xml file created by MetaData Backup needs to be sorted and reformatted before it can be accepted by Foobar2000. This involves trimming most of the columns in the xml file until only the relevant ones remain. These are then sorted based on the SourceURLs. Because I was transferring this to a new computer, a Find and Replace was performed on the SourceURL to replace the old URL prefix with a new one. This is so the correct files are accessed later on in the process. Make sure to follow the rules specified by MetaData Backup and do not change the filenames or arrangement of any songs in the new music directory.

Fig. 1 - Example of trimmed and sorted columns in Excel

As shown above, the three main columns of interest are UserPlayCount, AcquisitionTime, and UserLastPlayedTime. UserPlayCount is fine, but AcquisitionTime and UserLastPlayedTime must be reformatted before they can be imported correctly. The playback stastics component in Foobar2000 requires that dates be formatted yyyy-mm-dd hh:mm:ss (ex. 2008-09-27 06:38:17). This necessitates some tricky Excel reformatting to get everything fixed-up correctly.

To do this, I used Data > Text to Columns to separate the date and time as well as the three numbers inside each one. First, the columns are separated based on the space between date and time. The results are then separated based on the dashes or colons until the year, months, days and hour, minutes, and seconds and AM/PM are all in separate columns. The Data Format should be set to text to keep everything the way it is.

To display the hours in 24 hour format, I used a very simple IF statement to increment the hour values by 12 if a PM was found in the adjacent column. No change was required for AM times, but I added a 0 anyways to make them switch to number format.

ex.  =IF(G12="PM",D12+12,D12+0)

One of the more difficult parts was getting enough leading zeroes into the cells. To do this I used another IF statement to add a "0" if the cell was 9 or less.

ex. IF(J2>9,J2,0&J2)

Once all the fields were correct, they need to be put back together using &. This might take a couple of steps.

ex. =R15&":"&E15&":"&F15

After all this work, you should have a single column of dates/times that lines up with your original SourceURL and UserPlayCount columns. As this process ended up being fairly time consuming, I only bothered with AcquisitionTime since I didn't care about UserLastPlayedTime all that much.

I then grabbed everything under the SourceURL column and pasted it into a text file, which I then renamed as an m3u playlist file. It should look something like this:

Fig. 2 - m3u file with ordered list of all library item SourceURLs

I then created a new excel spreadsheet and pasted in the columns I wished to import. This is then saved as a .CSV file that looks something like this:

Fig 3 - CSV file with metadata separated by commas

As you can see, the data I want to add for each song is separated by commas and lines. This must align correctly with the original SourceURL or else the data will not be written to the correct files.

This next step requires a program to tag the music files using the files just created. I used Mp3tag. First, I loaded up the playlist.m3u I had made into Mp3tag. I then used  the very handy Convert > Text file - tag command to write tags to each library file:

Fig. 4 - Importing the metadata as file tags


Note that the Format string must mirror the metadata formatting in the .CSV file. It must also follow the naming conventions used by foo_playcount.

Once this has finished (it may take a few minutes depending on the size of your library), all you need to do it open up Foobar2000 and run the command Playback Statistics > Import statistics from file tags for All Music. This checks each music file for tags that hold any relevant metadata and updates the Playback Statistics database accordingly.

Fig. 5 - Song metadata with newly imported %PLAY_COUNT% and %ADDED% field tags


Fig. 6 - Song Properties with new Playback Statistics values


And there you have it. All your metadata should now be stored in Foobar2000. You can make sure everything is correct by checking the Properties of different files and then comparing this to your original WMP library. Personally, I had to manually update a couple of outlier files that did not update correctly. But for the most part, this method is robust and useful for transferring metadata for a large amounts of files.

2 comments:

  1. THANK YOU. Even though you posted this 9 years ago, it still worked for me, and I didn't have to reset my invaluable playcounts and metadata. THANK YOU SO MUCH!

    ReplyDelete
    Replies
    1. You're welcome! This blog is pretty much dead, but I am still around and still using Foobar2k!

      Delete