水一个通用代码- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (dir/a-d/s/b "%~dp0*.*")do (set "name=%%~nxi"&set "y="
- for /l %%n in (0,1,8192)do (
- if /i not "!name:~%%n,1!"=="" set "n=%%n"
- if /i "!name:~%%n,1!"=="-" set "y=y"
- )
- if defined y (
- for /l %%n in (0,1,!n!)do if /i "!name:~%%n,1!"=="-" set "new1=!name:~0,%%n!"&&set "new2=!name:~%%n!"&&set "new2=!new2:-=!"
- if /i "%%~nxi"=="!new1!-!new2!" (
- for /l %%n in (1,1,4)do set "new2=0!new2!"
- for /f "delims=" %%n in ("!new2!")do set "new2=%%~nn"
- set "name=!new1!-!new2:~-4!%%~xi"&echo/
- echo,old:"%%~fi"
- echo,new:"!name!"
- if exist "%%~fi\" (rem:
- echo,old:"%%~fi"
- echo,new:"!name!"
- )else (
- if exist "%%~fi" (rem:
- echo,old:"%%~fi"
- echo,new:"!name!"
- )
- )
- )
- )else echo,文件错误无分割符
- )
- pause
复制代码
|