LastFM2Itunes Perl Script


lastFM2Itunes is a perl script that updates iTunes tracks play count and play date with last.FM tracks information.


download latest version

What the script does

  • parses your lastFM data
  • looks for matching tracks in your iTunes library based on Artist/Song
  • if track found it updates the iTunes play count only if it is less than the last.FM one. Update the last play date too.
  • if enabled, data can be saved into a csv file



Tutorial: step by step tutorial with screenshots (PDF) [How to install Perl, and use the script]

  • open a command line shell to run a perl script
  • run "perl lastFMusername [t DD MM YYYY,v,csv filename]"
    • user: your lastFM account name. (mandatory)
    • t DD MM YYYY: (optional) enable to specify a starting date to begin the import (ie: 'perl lebios t 15 02 2008', to export my data from 15/02/2008)
    • v: (optional) enable verbose mode
    • csv: (optional) write data to csv file. In this case iTunes is not updated and verbose is on
      • provide a valid filename to save
    • sample: perl lebios csv lebios.csv > lebios.log
      this will poll all my profil info and copy them into lebios.csv file. Also the command line output will be written on lebios.log file and not on the screen

Origin of the script

Recently I lost my iTunes library and so had to rebuild it from scratch. That's not a big deal, but several of my smart playlists based on play count were useless since all the tracks count has been reset to 0.
On the other hand I always synchronised my iTunes with my lastFM account. So my tracks play counts were available there.


For any question (how to use the script), any problem, any wanted evolutions do not hesitate to contact me here.

Lionel Grenier

lastFM2iTunesManual.pdf443.88 KB
lastFM2Itunes.V0.65.zip6.64 KB

About the Author


If you've liked this free application, you can donate via Paypal, or you can get me (lebios) a subscription.


  • Site Counter: 14942
  • Unique Visitor: 6232
  • Published Nodes: 53
  • Since: 2008-10-01


free counters

User login