返回列表 发帖
  1. @echo off
  2. set f1=d:\from
  3. set f2=d:\to
  4. cd /d "%f1%"
  5. for /f "delims=" %%i in ('2^>nul dir /b /s /a-d *.txt *.rar') do (
  6. set f=%%i
  7. set nx=%%~nxi
  8. set x=%%~xi
  9. set n=1
  10. call :1 "%%~nxi"
  11. )
  12. pause
  13. exit
  14. :1
  15. for /f "tokens=1* delims=(" %%a in ("%~1") do (
  16. if "%%b" neq "" (
  17. call :1 "%%b"
  18. ) else (
  19. for /f "tokens=* delims=0123456789" %%c in ("%%a") do (
  20. if "%%c" equ ")%x%" (
  21. call set "str=%%nx:(%%a=%x%%%"
  22. ) else (
  23. set "str=%nx%"
  24. )
  25. setlocal enabledelayedexpansion
  26. for /f "delims=" %%e in ("!str!") do (
  27. endlocal
  28. call :2 "%%e"
  29. )
  30. )
  31. )
  32. )
  33. exit /b
  34. :2
  35. set /a n+=1
  36. if not exist "%f2%\%~n1%~x1" (
  37. copy "%f%" "%f2%\%~n1%~x1"
  38. ) else if not exist "%f2%\%~n1(%n%)%~x1" (
  39. copy "%f%" "%f2%\%~n1(%n%)%~x1"
  40. ) else (
  41. goto :2
  42. )
  43. exit /b
复制代码
bat小白,请多指教!谢谢!

TOP

返回列表