- @echo off
- setlocal enabledelayedexpansion
- echo;请将需要处理的文件夹拖放进本窗口
- set /p folder=
- for /f "delims=" %%i in ('dir /ad /s /b %folder%') do set/a n+=1&&set .!n!=%%~fi
- (for /l %%n in (!n!,-1,1) do if defined .%%n echo;!.%%n!)>tmp.x
- for /f "delims=" %%a in (tmp.x) do (
- cd /d "%%~fa"\..
- set "fn=%%~nxa"
- set "fnw=%%~nxa"
- for /f "tokens=1-5 delims=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-." %%1 in ("%%~nxa") do (
- if not "%%1%%2%%3%%4%%5"=="%%~nxa" (
- call :change "%%1" "%%2" "%%3" "%%4" "%%5"
- ) else (
- call :chun
- )
- )
- )
- cd /d "%~dp0"&del /f /q tmp.x
- echo;处理完毕&pause>nul&exit /b
-
- :change
- for %%b in (%~1 %~2 %~3 %~4 %~5) do set "fnw=!fnw:%%b=!"
- set "fnw=!fnw: =!"
- set /a m=1
- if exist !fnw! (
- :judge
- if exist !fnw!_!m! (
- set /a m+=1
- goto judge
- )
- ren "!fn!" "!fnw!_!m!"
- goto :eof
- )
- ren "!fn!" "!fnw!"
- goto :eof
-
- :chun
- set /a m=1
- if exist chunhanzi (
- :panduan
- if exist chunhanzi_!m! (
- set /a m+=1
- goto panduan
- )
- ren "!fn!" chunhanzi_!m!
- goto :eof
- )
- ren "!fn!" chunhanzi
- goto :eof
复制代码
|