generating a playlist using itunesdb

AMG created a wonderful utility called itunesdb which allows you to retrieve information from an ipod in regards to the music stored on it.

Below is just one example of how to utilize the itunesdb package:


 #!/usr/bin/tclsh
 package require itunesdb 
 set ::basepath "d:"
 set ::db [itunesdb $::basepath/iPod_Control/iTunes/iTunesDB]
 proc genlist {} {
  $::db seek track
  set ::fp [open playlist.m3u w+]
  while {[$::db remaining]} {
   array unset track
   array set track [$::db read]
   puts $::fp "$::basepath[string map {: /} $track(ipod_path)]"
  }
  close $::fp
  $::db destroy
  puts done
 }

 genlist

Simply change ::basepath to where your ipod is mounted, and run the script. The script will generate a file called playlist.m3u in the same directory it is stored in, hopefully allowing you to play the music from your ipod over your pc. More features, possibly, to come.