• 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: Is this possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this possible?


  • Subject: Re: Is this possible?
  • From: Emmanuel <email@hidden>
  • Date: Wed, 28 Feb 2001 21:19:09 -0600

At 0:12 -0600 28/02/01, Ian Sterling wrote:
> I would like to be
>able to have applescript choose a specified number of random mp39s and copy
>them to my mp3 folder on my powerbook. The part that has me stumped is
>choosing the random files.

Here is how I should go. Not providing the full solution, just a few hints.

1. build a list of the paths of all the files. Say we name it "theList"
2. count it:
-----------------
set nFiles to (count theList)
-----------------

3. choose randomly an item:
-----------------
set anIndex to random number from 1 to nFiles
set aPath to contents of item anIndex of theList
-----------------

4. copy it into the PB

5. delete it from the list, and update the counter:
-----------------
set theList to (suppress item anIndex from theList)
set nFiles to nFiles - 1
-----------------
(requires the free Satimage osax)

Repeat steps 3 - 4 - 5 as many times as needed.

HTH
Emmanuel


References: 
 >Is this possible? (From: Ian Sterling <email@hidden>)

  • Prev by Date: Re: I want to convert a list of integers to their negative self
  • Next by Date: Re: Scripting Additions
  • Previous by thread: Is this possible?
  • Next by thread: Re: global variable not being recognized by script object su
  • Index(es):
    • Date
    • Thread