Skip to content

Instantly share code, notes, and snippets.

@katsuma
Created June 20, 2012 17:12
Show Gist options
  • Save katsuma/2960993 to your computer and use it in GitHub Desktop.
Save katsuma/2960993 to your computer and use it in GitHub Desktop.
Add a sound file to iTunes Library
file = MacTypes::FileURL.path(File.expand_path('/tmp/speech.aiff'))
command = "tell app \"iTunes\" to add \"#{file.hfs_path}\""
exec_command = "osascript -e '#{command}'"
`#{exec_command}`
tell application "iTunes"
set added_track to add "Machintosh HD:private:tmp:tmp.aiff"
play added_track with once
delay 5
set loc to (get location of added_track)
delete added_track
tell application "Finder"
delete loc
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment