Unfortunately, batch does not have a built-in method to generate alphabets, but using
for loop, we can ‘generate’ alphabets.
This is a simple idea of how this works.
set /a result=(%random%*26/32768)+1 for /f "tokens=%result%" %%I in ("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") do ( echo %%I )
- The first
set /astatement generate a random number
Nbetween 1 to 26
for /fstatement picks the
Nth item from a list of A to Z.
- Return the result
One can put a total
31 items in 1
for loop, and practically unlimited items using [this method].(Batch – for loop parameter order
if you want to reproduce, please indicate the source:
batch-file – Random In Batch Files – Random Alphabets - CodeDay