@echo off for %%a in (*.*) do ( if "%%~nxa" neq "%~nx0" ( set "name=%%~na" setlocal enabledelayedexpansion set name1=!name! call :lp ren "!name!%%~xa" "!nam!%%~xa" set "nam=" endlocal ) ) pause :lp if defined name1 ( set "var=!name1:~,1!" if "!var!" leq "Z" ( if "!var!" geq "a" ( set "nam=!nam!!var!" )) set "name1=!name1:~1!" goto lp )
batman:
复制代码 代码如下:
@echo off set "code=a b c d e f g h i j k l m n o p q r s t u v w x y z" for /f "delims=" %%a in ('dir /s /a-d /b') do ( if "%%~nxa" neq "重命名.bat" ( set "str=%%~na"&set "file=%%a"&set "var=%%~na" setlocal enabledelayedexpansion for %%i in (%code%) do set "str=!str:%%i=!" set "str=!str: =!"&call :lp ren "!file!" !files!%%~xa endlocal )) goto :eof :lp set /a n+=1 for /f "tokens=%n% delims=%str% " %%a in ("%var%") do ( if "%%a" neq "" set "files=!files!%%a"&goto lp )