posted to this is not a weblog
on jan 27th, 2009 at 03:22

tagged android, g1, mac, nerd, ruby
and commented on once

share this page

i finally got around to putting music on my g1 and wanted a simple way of synchronizing an itunes playlist with a directory on the g1's sd card while it was connected over usb, just like my iphone used to once it was docked.

i found synctunes which is free (though not available on the author's site anymore for some reason) but it didn't preserve any directory structure on the destination and just lumped all of the files into one big directory.

i then found salling media sync which did just what i wanted, but in its unregistered mode it doesn't really sync intelligently and just deletes all the files and copies them every time. it looked nice and did what i wanted so i was going to register it, until i found out they wanted twenty two fucking dollars for this little utility. ridiculous.

i saved my $22 and wrote itunes-rsync. it's a command-line ruby script that pulls all of the filenames out of an itunes playlist (using the nifty rubyosa module), creates a scratch directory and builds symlinks to each of the real files, then just calls rsync and lets it do all the magic of figuring out what needs to be copied and deleted.

$> ruby itunes-rsync.rb ipod /Volumes/ANDROIDMMC/Music/
querying itunes for playlist "ipod"... found 794 tracks.
linking files under /tmp/itunes-rsync.QnLco/... done.
rsyncing to /Volumes/ANDROIDMMC/Music/... 
building file list ... done

sent 32611 bytes  received 20 bytes  65262.00 bytes/sec
total size is 7355076387  speedup is 225401.50
cleaning up... done.

normally it would list all the files it's copying or deleting but i already ran it so it just did a quick comparison and exited without having to transfer anything.

i suppose it could use some bells and whistles to do things like check that the playlist size won't overflow the card and handle podcasts, but it works for me.

note: the script uses rsync's --delete option, so make sure the destination directory is only used for music. anything else that's in it will get deleted, so don't yell at me if it wipes out everything on your sd card.

one comment

Pierre (not authenticated) on june 25th, 2009 at 01:59:51:

Works very well!! awesome and simple!!


leave your comment or contact me

if you want to be able to mark your comment as authentic or delete it later, include your e-mail address (it won't be shown on the site). you'll be e-mailed instructions with a copy of your comment.

basic html allowed; be nice
required


optional


optional