当时测试的时候用的小文件,没有考虑到文件大小单位,修改如下:- @echo off
- rem 批处理保存为ansi编码格式
- set f1=d:\1
- set f2=d:\2
- set f3=d:\3
-
- set "_f1=%f1:~0,1%"
- for /f "tokens=1* delims=:" %%a in ('robocopy "%f1%." "%f2%." /e /xc /xn /xo /l /x /fp ^|findstr /rb /c:" *新文件" /c:" *新目录"') do (
- echo 新文件\目录 [%_f1%:%%b]
- set "file=%_f1%:%%b"
- setlocal enabledelayedexpansion
- for /f "delims=" %%x in ("!file:%f1%=%f3%!") do (
- endlocal
- if exist "%_f1%:%%b\" (
- md "%%x" 2>nul
- ) else (
- md "%%~dpx" 2>nul
- copy "%_f1%:%%b" "%%x"
- )
- )
- )
- pause
复制代码
|