Today I saw too many excellent works here and am so excited that I can't sleep. Suddenly, I thought of a question. It's about the usage of the RANDOM variable. I searched online but couldn't find it, and G (Google) didn't find it either. I thought it shouldn't be a very naive question, so I dare to ask the seniors here. Thank you first.....
First, let's talk about my understanding of "random". It is a variable in WINDOWS, and in DOS, it can be called in the form of %random% like calling %USERNAME%, which can list random decimal numbers between 0 and 32767, right?
Question 1: There are TXT files with filenames from 1 to 20 (1.TXT to 20.TXT) in a folder. How to write a batch file to randomly call one of these 20 files?
Question 2: If the filenames of the 20 files in this folder are in Chinese (also TXT), how to randomly call one TXT?
First, thank you all for your enthusiastic help.
In the past two days, I found a new problem:
When randomly selecting a file in a certain folder, if this batch file is also in it, it may be selected. How to exclude the batch file itself?
(Assuming there are many types of files in the folder, including other batch files; at the same time, it is stipulated that this batch file must be in it)
Moreover: If there are several other files that also want to be excluded from randomness, how to do it? The filename can be represented by *.*.
How to achieve it? Thank you!
[ Last edited by HAT on 2008-10-27 at 11:29 ]
First, let's talk about my understanding of "random". It is a variable in WINDOWS, and in DOS, it can be called in the form of %random% like calling %USERNAME%, which can list random decimal numbers between 0 and 32767, right?
Question 1: There are TXT files with filenames from 1 to 20 (1.TXT to 20.TXT) in a folder. How to write a batch file to randomly call one of these 20 files?
Question 2: If the filenames of the 20 files in this folder are in Chinese (also TXT), how to randomly call one TXT?
First, thank you all for your enthusiastic help.
In the past two days, I found a new problem:
When randomly selecting a file in a certain folder, if this batch file is also in it, it may be selected. How to exclude the batch file itself?
(Assuming there are many types of files in the folder, including other batch files; at the same time, it is stipulated that this batch file must be in it)
Moreover: If there are several other files that also want to be excluded from randomness, how to do it? The filename can be represented by *.*.
How to achieve it? Thank you!
[ Last edited by HAT on 2008-10-27 at 11:29 ]


