I wrote an article on renaming a folder a long time ago, and found that it is slightly imperfect. Its main function is to add characters before the folder name, or add characters after the folder name. Some netizens responded that the function is too good. single. Today, I took a closer look at the bat batch code, which can completely rename folders and completely rename files, and now share with you.
Method/Step - Rename Folder
-
Take a few new folders as an example.
-
Create a new txt text document with any file name
-
Edit this txt text file and enter the following characters
set a=1000
setlocal EnableDelayedExpansion
FOR /f "tokens=*" %%i IN ('dir /a:d /b') DO (
set /A a+=1
ren "%%i" "电影!a!"
)
then save
-
After saving, change the file extension to bat, and there is a prompt to select "Yes"
-
Double-click to run this bat batch file, and after a little delay, the folders have all been renamed
-
The code mainly pays attention to the following two points, which can be modified at will
-
After these two modifications, the name of the renamed folder after running also changes.
END
Method/Step 2 - Rename the file
-
Taking renaming the txt file as an example, also create a new bat file first, and the code is as follows
@echo off
set a=00
setlocal EnableDelayedExpansion
for %%n in (*.txt) do (
set /A a+=1
ren "%%n" "小说!a!.txt"
)
Pay attention to the 4 places marked in red, you can make changes
-
After double-clicking, the effect is as follows
END