• 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: <email@hidden>
  • Date: Tue, 20 Apr 2004 08:42:06 -0700 (PDT)

> Date: Thu, 15 Apr 2004 16:24:24 +0100
> Subject: Re: Get iTune File Track by Alias
> From: Nigel Smith <email@hidden>
> To: Applescript Users List <email@hidden>
>
> 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

But, for this to work, doesn't it assume that 'location of every file track of
playlist "Library"' will be alphabetically sorted? Is that really a safe
assumption? I thought songs were listed in the library in the order you added
them so they could very quickly become listed out of order.

-jdr
_______________________________________________
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: Nigel Smith <email@hidden>
  • Prev by Date: Re: Quark Xpress 6
  • Next by Date: Re: Entourage Note -> Structured Text?
  • Previous by thread: Re: Get iTune File Track by Alias
  • Next by thread: Re: Get iTune File Track by Alias
  • Index(es):
    • Date
    • Thread