批处理如何把几个词语 随机组合?
发布网友
发布时间:2022-05-03 03:42
我来回答
共1个回答
热心网友
时间:2022-07-01 21:35
::code by nameyu8023 cmd@Win8
@echo off
mode con: cols=80 lines=20
color 3b
title 获取随机字符串
echo\
echo\
echo 获取随机位数,随机长度字符串。
echo\
echo\
set "str=abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ@#$\/+-_[]{}~`?"
set /p str=字符串范围(默认a-z 0-9 A-Z 特殊字符)
echo %str%
set strbit=100
set /p strbit=获取次数(默认100):
echo %strbit%
set strlengths=20
set /p strlengths=最大长度(默认20):
echo %strlengths%
::-------------------------------------
setlocal enabledelayedexpansion
call :strnum 2000
for /l %%a in (1,1,!strbit!) do (
call :sj !strlengths!
title 第[%%a/%strbit%]次正在生成,长度[!sj!]位
for /l %%b in (1,1,!sj!) do (
call :sj !strnum!
call :str !sj!
set tmpstr=!tmpstr!!tmpstr1!
)
echo %%a. !tmpstr!
set tmpstr=
)
title Over
pause
exit
:strnum
for /l %%a in (1,1,%1) do (
if "!str:~%%a,1!"=="" (
set strnum=%%a
goto :eof
)
)
goto :eof
:sj
set /a sj=%random%%%%1
goto :eof
:str
set tmpstr1=!str:~%1,1!
goto :eof
这样的?