Re: test a range of numbers
Re: test a range of numbers
- Subject: Re: test a range of numbers
- From: Michelle Steiner <email@hidden>
- Date: Wed, 23 Oct 2002 14:34:14 -0700
Begin forwarded message:
On Wednesday, October 23, 2002, at 01:25 PM, danday wrote:
but I would like to avoid so many if/else statements. Any suggestions?
A lot depends on how many groups you have; for simplicity's sake, I'm
assuming that there are three groups, 00 through 33, 34 through 66, and
67 through 99
set first_third to {}
set second_third to {}
repeat with loop from 1 to 33
set the_text to text -2 thru -1 of ("0" & loop)
copy the_text to end of first_third
end repeat
repeat with loop from 34 to 66
set the_text to loop as text
copy the_text to end of second_third
end repeat
Then inside a repeat loop for the files have this line:
set prefix to text 1 thru 2 of filename
if prefix is in first_third then
--move the file
else if prefix is in second_third then
--move the file
else
--move the file
end
If there is any possibility that the file name will begin with anything
other than two digits, you will have to use a third loop for last_third
and test file names for that, and have an error-handling routine.
It still uses if-then-else, but not nearly as many as checking for each
possibility separately.
Obviously, you will need to redefine the groupings depending on how
many folders you need to move the files to.
--Michelle
Never play strip Tarot.
_______________________________________________
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.