1.批量给文件夹命名
@echo off cd /d %~dp0 setlocal enabledelayedexpansion set num=20211228_ for /F "delims=" %%i in ('dir /B /A:D') do ( ren "%%i" "!num!%%i" REM set /A num=!num!+1 )
2.批量给文件命名
@echo off SETLOCAL ENABLEDELAYEDEXPANSION set /A num=0 FOR /F "tokens=*" %%i in ('dir /A-D /B /OD /TC') do ( IF NOT "%%i"=="%~n0%~x0" ( set /A num+=1 if !num! LSS 10 ( ren "%%i" 0000!num!%%~xi ) ELSE ( if !num! LSS 100 ( ren "%%i" 000!num!%%~xi ) ELSE ( if !num! LSS 1000 ( ren "%%i" 00!num!%%~xi ) ELSE ( if !num! LSS 10000 ren "%%i" 0!num!%%~xi ) ) ) ) ) ENDLOCAL exit