I'm trying to determine the path of track selected in iTunes using applescript. It doesn't seem to be a property of the track. Can anyone tell me how I can get the file path.
Thanks Kartik
I'm trying to determine the path of track selected in iTunes using applescript. It doesn't seem to be a property of the track. Can anyone tell me how I can get the file path.
Thanks Kartik
Try this:
--gets file path of selected song
tell application "iTunes"
set songLocation to get location of selection
end tell
return songLocation
--gets file path of currently playing song
tell application "iTunes"
set songLocation to get location of current track
end tell
return songLocation
If it's not available through AppleScript, your best bet will be to open and parse the iTunes plist file. If you only need static information, you're golden. If you need dynamic information (for example, info on the track that's currently playing), you'll want to get the track's persistent ID through AppleScript, then parse the plist file and lookup any info you need (including location, which has the full path).
For parsing that plist XML file (in ~/Music/iTunes/iTunes Music Library.xml), you can use ruby or python or any other language you like. If you like python, try this library: