A,B两个文件各N行
让A文件每行的结尾所添加的内容都是B文件中随机抽取的,该怎么写呢??
让A文件每行的结尾所添加的内容都是B文件中随机抽取的,该怎么写呢??
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%i in ('findstr /n .* a.txt') do set max=%%i
for /f "delims=" %%a in (b.txt) do call :couq&echo %%a!num!
pause
exit
:couq
set /a sui=%random%%%%max%+1
for /f "tokens=1* delims=:" %%i in ('findstr /n .* a.txt') do (
if "%%i"==!sui! set num=%%j&goto :eof
)
goto :eof
setlocal enabledelayedexpansion
for /f "delims=" %%a in (A.txt) do (
call :loop
echo %%a!str_temp!>>C.txt
)
:loop
set /a rand_num=%random%%%5+1
set num=1
for /f "delims=" %%i in (B.txt) do (
if !num!==%rand_num% (
set str_temp=%%i
goto :eof
)
set /a num=!num!+1
)