Script: iTunes/Copy Paths to Selected Tracks

This is the second in a series of posts about the scripts I use with FastScripts.

  • Script: Copy Paths to Selected Tracks
  • Application: iTunes
  • Suggested key binding: ⇧⌘C


itunes = Appscript::app("iTunes")
tracks = itunes.selection.get
paths  = { |track| track.location.get(:result_type => :alias).to_s }
open('|pbcopy', 'w') { |io| io.write paths.join("\n") }

This script copies to the clipboard the paths to the tracks you currently have selected in iTunes.

If multiple tracks are selected, all paths are copied, each on a separate line.

Yes, it’s just like the previous script. That one was for the Finder, this one is for iTunes. And yes, in FastScripts you can assign the same keyboard shortcut to different scripts for different apps. Awesome, right?

No hand-holding this time. Get the standalone script file, or git pull if you’re keeping a git clone of the scripts.

Got comments? Use reddit and/or poke me on twitter.