中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-05 11:37
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » How to batch rename folders
Printable Version  1,137 / 3
Floor1 zxlxsqzy Posted 2007-08-05 13:16
初级用户 Posts 47 Credits 126
For example, under my E:\11 folder there are a lot of folders, 132132 ghsdkj hkw437....... the names have no pattern. I want to rename them according to a certain pattern, for example 001 002 003......
What should I do?
I searched the forum, and there are only ones about renaming files, none about renaming folders.
Floor2 wudixin96 Posted 2007-08-05 16:04
银牌会员 Posts 931 Credits 1,928
Use

ren command or move command
Floor3 zxlxsqzy Posted 2007-08-05 16:26
初级用户 Posts 47 Credits 126
I of course know to use the ren command.
Help me take a look at what's wrong with what I wrote.
@echo off
dir /a /b E:\11 >1.txt
for /f %%i in (1.txt) do (for /L %%c in (1,1,20) do (ren e:\11\%%i %%c))


The first time I run it it's fine, but the next time I run it (after new folders have been added inside) it goes wrong, saying it can't find the file or that the name is duplicated.
Floor4 wudixin96 Posted 2007-08-05 16:46
银牌会员 Posts 931 Credits 1,928


Look at this. If the number of folders is under 1000, this will work.

If it exceeds one thousand, change call ren "%%i" %%num1:~-4%%

Set it to however many digits the quantity has.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023