Restarting the Mac resets the sequence. The first time this line is called after a restart, it begins with that same first “random” selection and goes through the same sequence.
You're not the first one to experiment that. See this old thread.
As far as I can tell, some will return the same sequence of "random" numbers starting with its first call after a system startup.
So random number seems needed. It can work from a seed.
This example isn't fully random, since the seed, current date, changes only once a second, but for many purposes that's good enough:
set n to random number from 1 to (count of [aFolder]) with seed (seconds of (current date))
I don't know what's your version of Mac OS X, but here's what can be found in the AppleScript Release Notes about the bug fixes made in Mac OS X 10.3: “The arbitrary element reference form
some itemwasn’t very random. This has been fixed. ”
FIrst, try resetting the PRAM. As far as I can think, the most likely cause of this effect would be that the system is seeding its random number generator with the exact same 32/64-bit integer at startup. That speaks to something being off at a very low level, which a PRAM reset might shake loose.
If that doesn't solve the problem, could you explain precisely what you do to make this happen - i.e., give us the whole script (it it's not too long) and tell us how and when it gets launched? There are only three other ways I can think of to get this effect, and they are all far-fetched:
- You run this applescript so early in the startup process that the system hasn't been fully initialized.
- You've added a bad or outdated third-party scripting addition that's interfering with the way applescript works.
- You're running the command in a context that has (somehow) redefined the some keyword.
I'm betting on the PRAM thing, though, because everything else is a bit crazy.