|
|
发表于 2020-9-20 09:03:46
|
显示全部楼层
回复 1# chreng
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/6lbb97qUOs1sTyKJfN0ZEQ- @echo off
- setlocal enabledelayedexpansion
- set "FileNum=10"
- set "LoopNum=3"
- set "LoopCount=1"
- set /p LoopNum=输入循环次数:
- :BeginLoop
- for /f "delims=" %%i in ('dir /b /a-d *.txt ^| findstr /v /x /c:"out.txt" /c:"end.txt"') do (
- set "_!random!=%%i"
- )
- set "FileCount=0"
- (for /f "tokens=2 delims==" %%i in ('set _') do (
- set /a FileCount+=1
- if !FileCount! leq %FileNum% (
- echo file './%%i'
- )
- ))>"out.txt"
- copy /b "out.txt"+"D:\a.txt" end.txt
- echo 已完成第 !LoopCount! 次随机抽取及合并,请检查文件 end.txt
- pause
- set /a LoopCount+=1
- if !LoopCount! leq %LoopNum% (
- goto :BeginLoop
- )
复制代码 |
评分
-
查看全部评分
|