大家好,我现在遇到一个很棘手的要求:
当前目录下有N个txt文件,需要产生随机数,
让每一个文件都重命名为随机数命名,后缀不变.
前面搜索出来的批量命名程序都不能这样修改.尤其是文件少的时候,产生的随机数很容易重复,我不知道如何避免重复,请各位帮助.
@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 ]
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.
@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 ]