- @echo off
- set f1=d:\from
- set f2=d:\to
-
- cd /d "%f1%"
- for /f "delims=" %%i in ('2^>nul dir /b /s /a-d *.txt *.rar') do (
- set f=%%i
- set nx=%%~nxi
- set x=%%~xi
- set n=1
- call :1 "%%~nxi"
- )
- pause
- exit
-
- :1
- for /f "tokens=1* delims=(" %%a in ("%~1") do (
- if "%%b" neq "" (
- call :1 "%%b"
- ) else (
- for /f "tokens=* delims=0123456789" %%c in ("%%a") do (
- if "%%c" equ ")%x%" (
- call set "str=%%nx:(%%a=%x%%%"
- ) else (
- set "str=%nx%"
- )
- setlocal enabledelayedexpansion
- for /f "delims=" %%e in ("!str!") do (
- endlocal
- call :2 "%%e"
- )
- )
- )
- )
- exit /b
-
- :2
- set /a n+=1
- if not exist "%f2%\%~n1%~x1" (
- copy "%f%" "%f2%\%~n1%~x1"
- ) else if not exist "%f2%\%~n1(%n%)%~x1" (
- copy "%f%" "%f2%\%~n1(%n%)%~x1"
- ) else (
- goto :2
- )
- exit /b
复制代码
|