回复 1# qd2024 - @echo off
- cd /d "%~dp0"
- setlocal enabledelayedexpansion
- set "MaxLen=0"
- for /f "tokens=2 delims=_" %%a in ('dir /b /a-d *_*.pdf') do (
- for /f "skip=1 delims=:" %%i in ('^(echo "%%a"^&echo.^)^|findstr /o ".*"') do (
- set /a StrLen=%%i-5-4
- )
- if !StrLen! gtr !MaxLen! (
- set "MaxLen=!StrLen!"
- )
- )
- set "MaxNum=1"
- for /l %%a in (1,1,!MaxLen!) do (
- set /a MaxNum=MaxNum*10
- )
- for /f "tokens=1* delims=_" %%a in ('dir /b /a-d *_*.pdf') do (
- set "FileNum=%%b"
- set "FileNum=!MaxNum!!FileNum:~0,-4!"
- ren "%%a_%%b" "%%a_!FileNum:~-3!%%~xb"
- )
复制代码
|