标题: [其他] 生成随机文件的bat代码求解释 [打印本页]
作者: 邹哥来了 时间: 2022-5-22 13:45 标题: 生成随机文件的bat代码求解释
请各位batchers解释一下这段代码的意思:- @echo off&setlocal enabledelayedexpansion
- set "str=abcdefghijklmnopqrstuvwxyz0123456789"
- set "code=jpg txt bat exe wma mp3"
- md test&cd test
- for /l %%a in (1,1,20) do (
- for /l %%b in (1,1,9) do (
- set /a a=!random!%%36
- call,set "var=!var!%%str:~!a!,1%%"
- )
- set /a b=!random!%%5+1&call :lp
- set "var="
- )
- goto :eof
- :lp
- for /f "tokens=%b%" %%c in ("%code%") do echo.>!var!.%%c
复制代码
本人新手,初入论坛,在此不胜感谢
作者: flashercs 时间: 2022-5-22 14:24
- @echo off&setlocal enabledelayedexpansion
- set "str=abcdefghijklmnopqrstuvwxyz0123456789"
- set "code=jpg txt bat exe wma mp3"
- md test&cd test
- for /l %%a in (1,1,20) do ( REM 20次
- for /l %%b in (1,1,9) do ( REM 生成9位随机文件名
- set /a a=!random!%%36
- call,set "var=!var!%%str:~!a!,1%%"
- )
- set /a b=!random!%%6+1&call :lp REM 随机后缀名
- set "var="
- )
- goto :eof
- :lp REM 生成空白随机文件
- for /f "tokens=%b%" %%c in ("%code%") do echo.>!var!.%%c
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |