utility to sync an itunes playlist to a directory (like a mounted sd card/phone)

use File.symlink

authored by

jcs and committed by jcs.org a52e38f3 1a3a0929

+6 -7
+6 -7
itunes-rsync.rb
··· 1 1 #!/usr/bin/ruby 2 - # $Id: itunes-rsync.rb,v 1.1 2009/01/27 08:49:12 jcs Exp $ 3 - # 4 - # rsync an itunes playlist with another directory, most likely a usb music 5 - # device 2 + # $Id: itunes-rsync.rb,v 1.5 2009/01/27 09:11:14 jcs Exp $ 6 3 # 7 - # requires the rubyosa gem ("sudo gem install rubyosa") 4 + # rsync the files of an itunes playlist with another directory, most likely a 5 + # usb music device. requires the rubyosa gem ("sudo gem install rubyosa") 8 6 # 9 7 # Copyright (c) 2009 joshua stein <jcs@jcs.org> 10 8 # ··· 92 90 end 93 91 94 92 # setup work dir 95 - td = `mktemp -d /tmp/itunesrsync.XXXXX`.strip 93 + td = `mktemp -d /tmp/itunes-rsync.XXXXX`.strip 96 94 97 95 # mirror directory structure and create symlinks 98 96 print "linking files under #{td}/... " ··· 102 100 tmppath = "#{td}/#{shortpath}" 103 101 104 102 if !Dir[File.dirname(tmppath)].any? 103 + # i'm too lazy to emulate -p with Dir.mkdir 105 104 system("mkdir", "-p", File.dirname(tmppath)) 106 105 end 107 106 108 - system("ln", "-s", t, tmppath) 107 + File.symlink(t, tmppath) 109 108 end 110 109 111 110 puts "done."