liyu963926475 当前离线
列兵
went 当前离线
少校
@echo off & cd /d "%~dp0" set "zero=000" for %%i in ("*.jpg") do ( set "head=" & set "foot=" call :split "%%~ni" call set "foot=%zero%%%foot%%" call set "foot=%%foot:~-3%%" echo %%i call echo %%head%%%%foot%%.jpg call move "%%i" "%%head%%%%foot%%.jpg" echo --------------------------- ) pause&exit :split set "str=%~1" if not "%str:~-1%"=="-" ( set "head=%str:~0,-1%" set "foot=%str:~-1%%foot%" call :split "%%head%%" ) else goto :eof复制代码
评分人数
TOP
WHY 当前离线
上校
@echo off setlocal enabledelayedexpansion for /f "delims=" %%i in ('dir /b *-*.jpg ^| findstr /i "\-[0-9]\.jpg$ \-[0-9][0-9]\.jpg$"') do ( set "Name=%%~ni" if "!Name:~-3,1!" == "-" ( ren "%%i" "!Name:~0,-2!0!Name:~-2!%%~xi" ) else ( ren "%%i" "!Name:~0,-1!00!Name:~-1!%%~xi" ) ) pause复制代码
PowerShell "dir *-[0-9].jpg, *-[0-9][0-9].jpg | ren -NewName {$a=$_.Name -split '(?<=-)(?=\d+\.jpg$)'; $a[0] + $a[1].PadLeft(7, '0')} -WhatIf"复制代码