Created
December 19, 2010 23:03
-
-
Save openfirmware/747804 to your computer and use it in GitHub Desktop.
Return iTunes Selection
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
(* | |
Return the quoted paths of the currently selected tracks in iTunes | |
Returns error if iTunes is not running | |
Call from command line with 'osascript -e itunes_selection.scpt' | |
*) | |
on run | |
tell application "System Events" | |
if (name of processes) contains "iTunes" is false then | |
return "Error: iTunes is not running" | |
end if | |
end tell | |
set paths to {} | |
tell application "iTunes" | |
set sel_list to selection of window 1 | |
repeat with i from 1 to (number of items of sel_list) | |
set sel to (item i of sel_list) | |
set ppath to POSIX path of file (location of sel as string) | |
set paths to paths & quoted form of ppath | |
end repeat | |
end tell | |
set AppleScript's text item delimiters to ASCII character 10 | |
paths as text | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment