- @echo off
- set FolderA=A
- set FolderB=B
- set FolderC=C
- set /a a=2, b=3
- set /p a=从%FolderA%中取出多少个文件:
- set /p b=从%FolderB%中取出多少个文件:
- echo 从%FolderA%中取出%a%个,从%FolderB%中取出%b%个
- pause
- setlocal enableDelayedExpansion
- set n=0
- for %%a in ("%FolderA%\*") do set "a_!random!_!n!=%%a"&set /a n+=1
- set n=0
- for %%a in ("%FolderB%\*") do set "b_!random!_!n!=%%a"&set /a n+=1
- set n=0
- for /f "tokens=1* delims==" %%a in ('set a_') do (
- if !n! geq %a% goto done1
- copy "%%b" "%FolderC%"
- set /a n+=1
- )
- :done1
- set n=0
- for /f "tokens=1* delims==" %%a in ('set b_') do (
- if !n! geq %b% goto done2
- copy "%%b" "%FolderC%"
- set /a n+=1
- )
- :done2
- echo;&echo 完成.&echo;
- pause
复制代码
|