文章标签 » bat

backup:window批处理随机乱序文件内容

@echo off
setlocal enabledelayedexpansion

set input=.\input.txt
set output=.\output.txt

if exist .\tmp.txt del .\tmp.txt
if exist .\tmp2.txt del .\tmp2.txt
if exist %output% del %output%

for /F "delims=" %%i in (%input%) do (
	echo !random!#%%i >> .\tmp.txt
)

sort .\tmp.txt > .\tmp2.txt
del .\tmp.txt

for /F "tokens=2 delims=#" %%i in (.\tmp2.txt) do (
	echo %%i >> %output%
)
del .\tmp2.txt
pause