我做了一个伪造下载文件的批次:
@echo off
call:set_random
:loop
call:set_random
echo %text1%
ping -n 0.5 127.0.0.1>nul
echo %text2%
ping -n 1.5 127.0.0.1>nul
goto loop
:set_random
set "rand=%random%"
set "text1=Downloading %rand%.file"
set "text2=Downloading %rand%_manager.file"
因此它显示了这一点:
正在下载12258.file
下载12258_manager.file
正在下载445878.file
下载445878_manager.file
正在下载248712.file
正在下载248712_manager.file等
此外,我希望随机生成文本以将其转换为:
下载keyframeshow12258.file
下载keyframeshow12258_manager.file
正在下载menu2_445878.file
正在下载menu2_445878_manager.file
正在下载windowframe248712.file
正在下载windowframe248712_manager.file等
目前我不知道如何做到这一点,有人可以帮助我吗? (非脚本之间的空格是为了避免不退格。)
随机词
第一个字(只有一个):
key
image
frame
tool
gui
window
size
lua
batch
java
ping
第二个字(相同):
frame
size
compatibility
time
runner
stroke
backup
wander
第三个单词(相同且可选):
start
truefalse
text
ref
caller
setter
looper
echoer
_onoffswitch
option
static
答案 0 :(得分:0)
一个简单的方法是创建一个数组。在this post上用rojo举个例子-您可以从“列表”中选择随机字符串。您还可以根据以下IF OR语句将随机变量设为2rd words
或3rd words
:
set String[0]=1
set String[1]=2
set /a "idx=%random% * 2 / 32768"
If "!String[%idx%]!"=="1" (
Goto List2
) ELSE (
Goto List3
)
RandomFile.bat:
@echo off
setlocal enabledelayedexpansion
:List1
set WordOne[0]=key
set WordOne[1]=image
set WordOne[2]=frame
set WordOne[3]=tool
set WordOne[4]=gui
set WordOne[5]=window
set WordOne[6]=size
set WordOne[7]=lua
set WordOne[8]=batch
set WordOne[9]=java
set WordOne[10]=ping
set /a "idx1=%random% * 11 / 32768"
:List2
set WordTwo[0]=frame
set WordTwo[1]=size
set WordTwo[2]=compatibility
set WordTwo[3]=time
set WordTwo[4]=runner
set WordTwo[5]=stroke
set WordTwo[6]=backup
set WordTwo[7]=wander
set /a "idx2=%random% * 8 / 32768"
:List3
set WordThree[0]=start
set WordThree[1]=truefalse
set WordThree[2]=text
set WordThree[3]=ref
set WordThree[4]=caller
set WordThree[5]=setter
set WordThree[6]=looper
set WordThree[7]=echoer
set WordThree[8]=_onoffswitch
set WordThree[9]=option
set WordThree[10]=static
set /a "idx3=%random% * 11 / 32768"
:Extension
set ExOne[0]=file
set ExOne[1]=cmd
set ExOne[2]=exe
set ExOne[3]=batch
set ExOne[4]=csv
set ExOne[5]=pdf
set ExOne[6]=jpg
set /a "idx4=%random% * 7 / 32768"
echo Downloading !WordOne[%idx1%]!!WordTwo[%idx2%]!%random%!WordThree[%idx3%]!.!ExOne[%idx4%]!
pause
goto List1