1、创建多个文件夹
MD test1 test2 test3 test4
2、读取文件夹下的文件名字,写入到文件中
@echo off dir /b D: est*.* >>D: estlist.txt ::加上/s 会读取目录下的子目录 PAUSE
3、将文件中的内容写入到另一个文件中
@echo off for /f "delims=" %%a in (D: est0.txt) do echo %%a >> D: est2.txt PAUSE
4、批量复制文件,并统计执行时间
@echo off REM ############# REM 批量复制指定目录下的所有文件,并统计执行时间的脚本 REM 1输入源文件路径 REM 2输入目标路径 REM 3输入创建次数 REM 3输入创建次数 REM ############## echo *******批量复制文件脚本******** :again_input set /p sour=输入源文件路径: set /p dest=输入目标文件路径: set /p coun=输入创建次数: :again_yn set /p yn=是否确认输入信息 Y/N: if %yn% ==y goto cont_copy if %yn% ==Y goto cont_copy if %yn% ==n goto again_input if %yn% ==N goto again_input echo 输入错误,重新输入! goto again_yn :cont_copy echo *************** echo 正在创建文件,请稍等... echo *************** set firTime=%time% set /a done =1 :loop set /a left = %coun% - %done% echo 第%done%/%coun%次循环..... REM ****************创建复制文件循环体*********** set destpath=%dest%\%done% for /f "tokens=* delims=" %%a in ('dir /s/b "%sour%" ') do ( if not exist %destpath% ( MD %destpath% ) xcopy "%%a" "%destpath%" /e /c /y /h ) REM ****************创建次数循环体*************** if %done%==%coun% goto loop_end set /a done = %done% +1 goto loop :loop_end set secTime=%time% echo *************** echo 创建完成... echo *************** SET /a fhr=%firTime:~0,2% SET /a fmi=%firTime:~3,2% SET /a fse=%firTime:~6,2% SET /a fms=%firTime:~9% SET /a shr=%secTime:~0,2% SET /a smi=%secTime:~3,2% SET /a sse=%secTime:~6,2% SET /a sms=%secTime:~9% set /a hours=%shr%-%fhr% set /a mins=%smi%-%fmi% set /a secs=%sse%-%fse% set /a ms=%sms%-%fms% if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms% if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs% if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins% if %hours% lss 0 set /a hours = 24%hours% if 1%ms% lss 100 set ms=0%ms% echo ********************** echo 开始时间[%firTime%] echo 结束时间[%secTime%] echo 消耗时间[%hours%:%mins%:%secs%:%ms%] echo ********************** PAUSE