SoFunction
Updated on 2025-04-08

Batch code for renamed folders with the first two digits

A batch script that renames all folders first two digits:

Copy the codeThe code is as follows:

@echo off&
setlocal enableDelayedExpansion
set n = 41029
for /f "delims=" %%a in ('dir /ad /b') do (set a=%%a
ren "%%a" 41029!a:~0,2!
)
pause


Explanation of the above code:

Among them, /ad only displays directories, which means removing files and only displaying folders.
/b is to use an empty format (no title information or summary).
Use it when using variables!!