Hello everyone, I'm currently facing a very tough requirement:
There are N txt files in the current directory, and I need to generate random numbers,
so that each file is renamed with a random number name, and the suffix remains unchanged.
The batch naming programs I searched for earlier can't modify like this. Especially when there are few files, the generated random numbers are very easy to repeat, and I don't know how to avoid repetition. Please help everyone.
[ Last edited by janeter on 2007-2-4 at 11:04 PM ]
There are N txt files in the current directory, and I need to generate random numbers,
so that each file is renamed with a random number name, and the suffix remains unchanged.
The batch naming programs I searched for earlier can't modify like this. Especially when there are few files, the generated random numbers are very easy to repeat, and I don't know how to avoid repetition. Please help everyone.
@echo off&setlocal ENABLEDELAYEDEXPANSION
for %%a in (*.txt) do call:mytest "%%a"
:mytest
set a=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
set /a a_=(%random%+62)%%62
set /a b_=(%random%+62)%%62
set /a c_=(%random%+62)%%62
set /a d_=(%random%+62)%%62
set /a e_=(%random%+62)%%62
set /a f_=(%random%+62)%%62
echo rename %1 !a:~%a_%,1!!a:~%b_%,1!!a:~%c_%,1!!a:~%d_%,1!!a:~%e_%,1!!a:~%f_%,1!.txt
rename %1 !a:~%a_%,1!!a:~%b_%,1!!a:~%c_%,1!!a:~%d_%,1!!a:~%e_%,1!!a:~%f_%,1!.txt
[ Last edited by janeter on 2007-2-4 at 11:04 PM ]
