• 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: test a range of numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test a range of numbers


  • Subject: Re: test a range of numbers
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 24 Oct 2002 01:23:44 +0100

danday wrote on Wed, 23 Oct 2002 15:25:21 -0500:

>Is it possible to have an "if" statement test for a range of numbers?
>
>for example
>
> if theFile begins with [1-3] then ...
>
>which would be true for any file that begins with the numbers 1, 2, or
>3. I'm working on a script that will move files into folders based on
>their names. The file names consist of 8 numbers such as 10236829. The
>folders are broken up so files are sorted depending on the first two
>digits like this:
>
>00-05
>06-09
>10-29
>30-49
>50-99

Successively eliminate the ranges that are too low.

-- If the filename really does consist of just eight digits then:
set sortCode to filename div 1000000
-- Otherwise: set sortCode to (text 1 thru 2 of filename) as number

if sortCode < 6 then
-- move the file to the first folder
else if sortCode < 10 then
-- to the second
else if sortCode < 30 then
-- the third
else if sortCode < 50 then
-- the fourth
else
-- the fifth
end if

Alternatively, if your wider ranges mean that a file name is more likely
to occur within them, you could speed up the process by trying them first:

if sortCode > 49 then
-- move the file to the last folder
else if sortCode > 29 then
-- to the fourth, etc.

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

  • Prev by Date: Re: Newbie Quark Scripting critique
  • Next by Date: Re: Scripting in Excel -> search different words in column and color them
  • Previous by thread: Re: test a range of numbers
  • Next by thread: Count in Filemaker Pro
  • Index(es):
    • Date
    • Thread