- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /a-d /b *.*') do (
- set "fn=%%~na"
- call :judge "%%~na" "%%~xa"
- )
- echo;over&pause>nul
- exit
-
- :judge
- setlocal
- set "fn=%~1"
- set "fx=%~2"
- for /l %%a in (0 1 35) do (
- if not "!fn:~%%a,1!"=="" (
- echo;!fn:~%%a,1!|findstr [a-Z0-9]>nul&&set "fn_=!fn_!!fn:~%%a,1!"||set "fn_=!fn_!_"
- ) else (
- ren;"%~1%~2" "!fn_!%~2"
- endlocal
- goto :eof
- )
- )
- ren;"%~1%~2" "!fn_!%~2"
- endlocal
- goto :eof
复制代码
|