Created
January 9, 2011 20:25
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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