This 'unique randomization' reminds me (don't laugh too hard) of APL.
It begs for the "?" operator (as I recall). In unary mode it returned
a random number <= the argument; in binary mode it returned "x" unique
random numbers <= the second argument. You could then accomplish the
entire dastardly deed by:
fileEOF?fileEOF
and assigning the resulting vector to a variable. You now have a
randomized list of record numbers.
How to do FREADDIR's in APL is left as an exercise for the reader :-)