• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get iTune File Track by Alias
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get iTune File Track by Alias


  • Subject: Re: Get iTune File Track by Alias
  • From: Nigel Smith <email@hidden>
  • Date: Thu, 15 Apr 2004 16:24:24 +0100

On 15/4/04 5:15, "Michael Terry" <email@hidden> wrote:

> 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:

How about using a binary search? I don't know how fast this is for a lot of
tracks -- I don't have many in iTunes, myself...

----------
tell application "iTunes"
set testFile to location of file track 15 of playlist "Library"
set theList to location of every file track of playlist "Library"
if theList contains testFile then
set trackNum to binSearch(testFile, theList, 1) of me
return file track trackNum of playlist "Library"
end if
end tell

on binSearch(aTerm, aList, aNumber)
if (count of aList) = 1 then
return aNumber
else
set midItem to (((count of aList) / 2) as integer)
copy items 1 thru midItem of aList to tmp
if tmp contains aTerm then
binSearch(aTerm, tmp, aNumber)
else
binSearch(aTerm, items (midItem + 1) thru -1 of aList, <line-break>
aNumber + midItem)
end if
end if
end binSearch
----------

What's the speed like for you people with monster playlists?

Nigel
_______________________________________________
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.


  • Follow-Ups:
    • Re: Get iTune File Track by Alias
      • From: Michael Terry <email@hidden>
References: 
 >Re: Get iTune File Track by Alias (From: Michael Terry <email@hidden>)

  • Prev by Date: Re: (no subject)
  • Next by Date: Re: Adding a doc icon flag
  • Previous by thread: Re: Get iTune File Track by Alias
  • Next by thread: Re: Get iTune File Track by Alias
  • Index(es):
    • Date
    • Thread