I wasn't able to find a good tool to do this, even though I'm sure some exist, but I noticed it was pretty simple to implement that myself. So I wrote this little tool you might find useful as well: https://github.com/carlonluca/ITunesEmbed.
The tool will parse the library, extract ratings and play counts and embed those values into the popularimeter frame of the ID3v2 tags of the mp3s in your collection.
How to BuildBuilding the tool is simple: you just need Qt 4 (Qt 5 should be ok as well, I don't think many changes are needed), taglib and LightLogger. You can install taglib using macports, aptitude or whatever you want.
How to UseThe tool is a command line tool. Run the application without params and the help will be shown. You'll need to export your library to XML using iTunes. Then, provide the absolute file path of the library XML and an email that you want to associate to the data (multiple popularimeter frames can be embedded into the mp3). Beware that all the popularimeter frames associated to the same email address will be removed.
Of course this is just a draft. So look at the code, check what it does and backup your library entirely before starting to do anything. I don't want to be responsible of course if you burn it :-)