组合分隔符默认为英文下划线(即_),因此文件名和文件路径不要有英文下划线(即_),不然还原会出错,组合而成的文件名过长时也会出错
复制- @echo off
-
- set "src=E:\A"
- set "dst=E:\B"
- set s=_
-
- for /r "%src%" %%a in ("*.xls") do (
- set file=%%a
- setlocal enabledelayedexpansion
- set file2=!file:~3!
- set file2=!file2:\=%s%!
- copy /y "!file!" "!dst!\!file2!"
- endlocal
- )
- pause
复制代码 还原- @echo off
-
- set "src=E:\A"
- set "dst=E:\B"
- set s=_
-
- for %%a in ("%dst%\*.xls") do (
- set file=%%~nxa
- setlocal enabledelayedexpansion
- set srcd=!src:~0,3!
- set srcp=!file:%s%=\!
- copy /y "!dst!\!file!" "!srcd!!srcp!"
- endlocal
- )
- pause
复制代码
|