Skip to content

Instantly share code, notes, and snippets.

@drfeelngood
Created January 9, 2011 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drfeelngood/771981 to your computer and use it in GitHub Desktop.
Save drfeelngood/771981 to your computer and use it in GitHub Desktop.
Simple script that helps in migrating mp3 files to one central iTunes library.
#!/usr/bin/env ruby
#= sweep-tunes
require 'rubygems'
require 'broom'
if ARGV.size != 1
puts "usage: sweep-tunes <path>"
exit
end
wdir = ARGV[0]
script = <<-EOS
tell application "iTunes"
launch
add file "%s" to playlist "Library" of source "Library"
end tell
EOS
Broom.sweep(wdir, :pattern => "*.{mp3,m4a}") do |file|
command = "osascript -e '#{script % [file.gsub('/', ':')]}'"
puts "#{command}"
stdout = `#{command}`
raise stdout unless $? == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment