Re: Get iTune File Track by Alias
Re: Get iTune File Track by Alias
- Subject: Re: Get iTune File Track by Alias
- From: Michael Terry <email@hidden>
- Date: Wed, 14 Apr 2004 21:15:19 -0700
On Apr 14, 2004, at 4:48 PM, email@hidden wrote:
Is there a way to find an iTune track given an alias to the file? I
get a type
mismatch whenever I try. This gives a "iTunes got an error: A
descriptor type
mismatch occurred."
tell application "iTunes"
set myAlias to location of item 1 of file tracks of playlist
"Library"
get file tracks of playlist "Library" whose location is myAlias
end tell
Seems simple enought that it would work to me.
Yes, what you tried should have worked. None of the alternatives I
thought of are very fun or fast. This is the best I could come up with:
on getTrackForAlias(aliasKey)
set lastTids to AppleScript's text item delimiters
try
set stringKey to aliasKey as Unicode text
tell application "iTunes" to tell library playlist 1
set AppleScript's text item delimiters to "::"
set eachLocation to location of file tracks as Unicode text
end tell
if stringKey is not in eachLocation then error "Key not found."
number 656
set AppleScript's text item delimiters to stringKey
set eachLocation to eachLocation's text items
set AppleScript's text item delimiters to "::"
set idx to count text items of eachLocation's first text item
if idx is 0 then set idx to 1
set text item delimiters to lastTids
tell application "iTunes" to return file track idx of library
playlist 1
on error eMsg number eNum
set AppleScript's text item delimiters to lastTids
error "Can't getFileTrackForAlias: " & eMsg number eNum
end try
end getTrackForAlias
Mike
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.