- @echo off
- set "SourDir=D:\123"
- set "DestDir=E:\132"
- set "OutFile=E:\outfile.txt"
-
- forfiles /p "%SourDir%" /s /m *.* /d 0 /c "cmd /c echo @path">"%OutFile%"
- for /f "usebackq delims=" %%a in ("%OutFile%") do (
- setlocal enableDelayedExpansion
- set "FilePath=%%~dpa"&&set "FilePath=!FilePath:%SourDir%=!"&&set "FilePath=!FilePath:~1,-1!"
- robocopy "%SourDir%\!FilePath!" "%DestDir%\!FilePath!" "%%~nxa"
- endlocal
- )
- pause&exit
复制代码
|