Moving Windows Media Player Ratings into iTunes

I tried to do this a while ago, and ran into problems with iTunes crashing when I tried to set ratings. I tried this again with iTunes 4.9 and it worked! I don’t know if it was my system that was at fault, or if it was an iTunes bug, but either way now I have an application that can read ratings from Windows Media Player 9 and write them into iTunes.

I do it by filename. All my music files are named {Artist} – {Album} – {Track} – {SongName} so I know they’re all unique. If you do something different, such that the same filename might be used by more than one song, then you’ll probably not want to use this program.

I wrote it in C#. Adding references to the iTunes Music Library COM object, and the Windows Media Player COM object gave me WMPLib and iTunesLib namespaces in my app.

1
2
using WMPLib;
using iTunesLib;

Reading from Windows Media Player is simple enough:

1
2
3
WindowsMediaPlayer wmp = new WindowsMediaPlayerClass();
IWMPMediaCollection mediaCollection = wmp.mediaCollection;
IWMPPlaylist allMedia = mediaCollection.getAll();

And then stepping through the playlist. Don’t forget that COM enumeration start from 1, not 0, so the for loop should look like:

1
2
3
4
for (int i = 1; i <= allMedia.count; i++)
{
 ...
}

While I’m reading the ratings out of WMP, I’m building a dictionary of filenames to ratings. Then I step through all the songs in the iTunes database, doing a quick dictionary lookup to see if I have a rating for each song.

The only tricky thing about this is the cast to IITFileOrCDTrack:

1
IITFileOrCDTrack track = (IITFileOrCDTrack)iTunes.LibraryPlaylist.Tracks[i + 1];

This seems to be necessary because a track in a playlist is the base class IITTrack, which doesn’t expose the location of the track. The cast will fail for some media types (like radio stations) so be ready to handle that.

I wrote my app using the .NET Framework 2.0 beta. You can download the binary here, but you’ll need a .NET Framework 2.0 beta to run it. It’s a simple command line app that, when run, will copy all the ratings from your Windows Media Player songs that have ratings, into any songs in iTunes that have the same filename and are not yet rated.

25 Responses to “Moving Windows Media Player Ratings into iTunes”

  1. Will Anjos Says:

    I have been hunting sites to see how I could do this and sad to find that apart from your solution, nobody seems to know. I develop in Delphi but really don’t fancy writing something to do it. I had given up and was seriously considering just doing it manually over time when late last night an easy solution popped to mind;

    1) Clear now playing list.
    2) Get all your 5 star rated songs onto the ‘now playing list’ (right-click option).
    3) File menu option to save the now playing list – as an m3u file.
    4) import playlist into itunes.
    5) mark every song in the playlist as 5 star
    6) repeat for each rating from 1 to 4

  2. stevex Says:

    That’s a clever solution! It’s probably scriptable as well.

  3. James Cox Says:

    Good solution.

    Not sure if this was obvious but you can set the rating of every song in an itunes playlist by selecting them all (Ctrl-A), going “Get Info” (Ctrl-I) then setting the rating in the dialog. Saved me a lot of clicking!

  4. Katharine Says:

    Absolutely brilliant stevex – well done!!!

  5. Ara Says:

    Nice Work! Way to slice through a lot of complex solutions with the simplicity of Ockham’s Razor.

  6. Daniel Says:

    Just wonder one thing.. I use wmp, and i think it’s great actually, don’t understand all the complaints about it..
    But since i must use iTunes to update my iPod and since i found a new cool feature called “shared music” i want to change to iTunes.
    I have rated alot of my songs and use the ratings for different things and i want to transfer them from wmp to iTunes as you guys.

    But when i import the playlists as Will Anjos says all the songs from the imported lists become ugly tagged, the artist is correct but the name is the entire name like “01 shooting star” insted of “shooting star”. Also since I’m swedish all å, ä and ö’s fall out. I guess it is some formatting thing with m3u-lists. When i add a map to the library the characters are correct and the filenames as well but not the rating.. And if i import m3u lists all songs appear double in the library..

    Anyone know how to fix?

  7. Lander Says:

    Thanks for the idea to use WMPLib and iTunesLib to import my ratings into iTunes from WMP. I just wrote a little program that will import your ratings from WMp to iTunes in C#.

    The core of my application is:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    iTunesLib.iTunesAppClass iTunes = new iTunesLib.iTunesAppClass();
    iTunesLib.IITLibraryPlaylist lib = iTunes.LibraryPlaylist;     
    iTunesLib.IITTrackCollection trackCol = lib.Tracks;
    foreach(iTunesLib.IITTrack track in trackCol)
        {                  
            if(track.Kind==iTunesLib.ITTrackKind.ITTrackKindFile)
            {
                IITFileOrCDTrack file = (IITFileOrCDTrack)track;                for(int i=0;itrack.PlayedCount)||((wmpSongs[i].Rating!=-1)&amp;&amp;(track.Ratingtrack.PlayedCount)
                        track.PlayedCount = wmpSongs[i].PlayedCount;                                                           
                                }                      
                            }
                        }
                    }
                }

    Please try it out at and give me some feedback.

  8. Lander Says:

    Forgot…
    you can download it from http://wmp2itunes.blogspot.com/

  9. Tony Says:

    I had the opposite problem, moving rated songs from iTunes into Windows Media player.
    Solution (inspired by “Will” above) which is pretty quick:
    1) Wipe your WMP library
    2) Sort iTunes by rating
    3) Select then drag and drop all 5 star songs into WMP library
    4) Rate all songs in WMP as 5 star (right click on one of the songs, rating option in menu)
    5) Select then drag and drop all 4 star songs into WMP library
    6) Sort WMP library by rating
    7) Select all the non-5 star songs (click on first non-5 star, scroll to bottom, hold shift while clicking on last song)
    8) Rate them as 4 stars

    repeat as necessary.

  10. versa-vicea? Says:

    Is there a way to move iTunes ratings into Windows Media??

  11. imajamoke Says:

    Eureka! Music ratings problem solved thanks to Will Anjos (above). This works for ALL music management applications.

    I too used the rating system, but instead used a combination of WMP, MediaMonkey and RedChair Software to sync my iPod. Yes, I tried to hold out, but I finally caved-in to iTunes.

    So, follow these steps to transfer your ratings to an iPod from any music application.

    1. Open “whatever” program you have been using to manage your music, i.e. WMP, MediaMonkey, etc…
    2. Create a playlist for each of your star ratings (i.e., one for 1 stars, another for 2 starts, and so on…)and save each as a m3u file.
    3. Open iTunes
    4. Import each m3u file
    5. Next, look under playlists…whala, there are your ratings!!!
    6. Next, just run through each of your playlists and “recheck” all your ratings…this will transfer into the iTunes library.

    Cheers!

  12. Kerry Says:

    http://www.download.com and look for a program called MusicBridge. This will sync between itunes and wmp and back again. It doesn’t do it very elegantly however it works and saves you writing it.

  13. Al Says:

    I am in the process of going from a PC to a Mac, and I have been looking for a way to transfer my music library with my ratings intact. The methods posted here seems only to be working when you are going to a new program but on the same computer. I have to transfer to a new program, on a new computer with a different operating system ;)

    Inspired by the playlist method above I came up with the following method that should be able to work from most programs to any media player (also on another computer and OS). It uses MediaMonkey’s fabulous Auto-Organizing-function, but MediaMonkey can automatically import libraries from WMP and other players with ratings, so those who doesn’t normally use MediaMonkey could still use this method.

    1 – If you don’t already have your music library and ratings in MediaMonkey, import your current library into MediaMonkey: http://www.mediamonkey.com/faq/index.php?sid=257711&lang=en&action=artikel&cat=373732&id=81&artlang=en

    2 – Sort your entire library by rating
    3 – Choose all files rated 5 and Auto-Organize files (Ctrl+R), and save the files in a folder called “Rating 5″
    4 – Move all the files in the “Rating 5″ folder to your new computer
    5 – Add the files to the library and rate them all 5

    6 – repeat step 2-5 for each rating
    7 – transfer the remaining (unrated) files and import to library

  14. dkl Says:

    I decided to give iTunes a try while debating on iPhone. Unfortunately the .m3u method didn’t work for me because of my Unicode file names. Luckily Steve’s RatingMover worked as advertised. :)

  15. Kristoffer Trolle Says:

    Thanks for the information on how to convert the ratings! I made my own program though that didn’t used filenames as identifier, but artistname+trackname+albumname. Also I only transferred the ratings on songs that got 5 stars in WMP. I don’t care about the ones that got less than that.

    You can see my code here:
    http://www.diku.dk/hjemmesider/studerende/ktmm/files/Program.cs

    ..or download the program here:
    http://www.diku.dk/hjemmesider/studerende/ktmm/files/WmpRatingsToiTunes.exe

    Hope someone can use it.

  16. Hawkgutz Says:

    If you need to transfer playlists from iTunes you can use iTunesExport to convert them into m3u files. To transfer your ratings I would make playlists in iTunes for every rating (1,2,3,4,5), turn them into m3u, then select all songs in each playlist and assign them the same rating on wmp.

  17. Alex Says:

    Kerry Your the best, Music Bridge is the bestest!

  18. Jim Says:

    Will Anjos you’re a genius!

  19. Miguel Durazo Says:

    Great man!, thank u so much

  20. Miguel Roman Durazo Almeida Says:

    I love play counts, so i used ur code to pass that setting, it could be more complex than what i did but im satisfied with the results this gave me. heres the code.
    static WindowsMediaPlayer wmp = new WindowsMediaPlayerClass();
    static IWMPMediaCollection mediaCollection = wmp.mediaCollection;
    static IWMPPlaylist allMedia = mediaCollection.getAll();

    static void Main(string[] args)
    {
    Dictionary dict = new Dictionary();

    for (int i = 1; i <= allMedia.count; i++)
    {

    try
    {

    Console.WriteLine(allMedia.get_Item(i).name + ” Play Count: ” + allMedia.get_Item(i).getItemInfoByAtom(311));

    dict.Add(allMedia.get_Item( i ).name,Int32.Parse( allMedia.get_Item( i ).getItemInfoByAtom( 311 ) ));

    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message);
    }

    }

    iTunesAppClass itunes = new iTunesAppClass();

    for (int i = 1; i < itunes.LibraryPlaylist.Tracks.Count; i++)
    {

    try
    {

    IITFileOrCDTrack track = (IITFileOrCDTrack)itunes.LibraryPlaylist.Tracks[i + 1];

    track.PlayedCount = dict[track.Name];

    Console.WriteLine(“Setting play count = “+ dict[track.Name]+” On the file “+ track.Name );

    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message);
    }
    }

    }

    Thanks

  21. Miguel Roman Durazo Almeida Says:

    Now, i would like to write a software that automatically downloads lyrics from a website and places it on the itunes song, so i dont have to listen to it as some programs already do.
    i will start working on that, if somebody already knows or did something like that plz share

  22. jyoti swaroop Says:

    yeah i thought of the playlist option too. But its not synchronised. like i will be using both wmp and itunes from time to time. So this means i have to redo the rating everyday!!

  23. Tony H Says:

    Thank you stevex …you are a genius…Thanks

  24. Tyler Says:

    All of the solutions I’ve read here are completely incorrect, I finally found a correct way to do this, with having NO DUPLICATES!!

    1) Create a playlist using wmp or something with all your 5 star songs
    2) Use the import playlist function on itunes to bring in those songs.
    3) If the tracks are not formatted right in itunes, or they have incorrect names, click the right arrow on the playlist. a screen will come up that says either put in imix format or “give playlist”. Click give playlist, and it will correctly tag all your songs in the playlist. I have no idea why this works, it just does.
    4) Now, add your main library, and itunes should tag most of it well, but at this point there will be duplicates of all your songs that you just imported that were rated.
    5) The weird part: HOLD SHIFT- and press the file button, and magically, a new option will come up under the file menu called ‘show exact duplicates’. This will only show the exact duplicates, and it will show both copies.
    6) Sort by rating, and remove all the unrated ones from your library, but make sure you don’t move them to recycle bin, just get them out of the library.

    It took me a long ass time to figure something out when itunes should have a ‘import native song info’ built in, itunes sucks but we have no choice, for those of us with ipods/iphones, we can’t use mediamonkey or anything else because apple makes sure there’s only one road out there, and we all have to drive on it…

  25. Dan Says:

    All of this has been taken care of by a free program at:
    http://www.orzeszel.org/dev/ratings
    Small, simple and it works perfectly.

Leave a Reply