Batch to Rename Directories/folders

May 22, 2010 at 07:11:01
Specs: Windows XP
Hi,
I am looking for a way to rename several folders at once, with the following criteria. The first folder can be created with some name "X," then 5 sub-folders inside "X" with the names "X1," "X2," "X3," "X4," "X5," where X will be some value, possibly entered by a user, and 1, 2, 3, 4, 5 will always be the same. Is there a batch file solution, or some other relatively simple method?
Thanks.

See More: Batch to Rename Directories/folders

Report •

#1
May 22, 2010 at 09:13:10
@echo off & setLocal EnableDELAYedeXpansion

set /p X=folder name ?

for /L %%a in (1 1 5) do (
md !X!\!X!%%a
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
May 22, 2010 at 11:02:05
Thank you Mechanix2Go. Works very well. Can I change the values of "(1 1 5)"? Essentially put in words so that the sub directories would be named "X word a", "X word b," etc. I tried to modify the code above, but unsuccessfully.

Report •

#3
May 22, 2010 at 12:14:04
The /L only works for numbers.

====================================
@echo off & setLocal EnableDELAYedeXpansion

set /p X=folder name ?

for %%a in (apple orange berry) do (
md !X!\%%a
)


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
May 22, 2010 at 13:37:23
Once again, thank you M2. I have modified it a bit as below:

@echo off & setLocal EnableDELAYedeXpansion

set /p X=folder name ?

for %%a in ("Apple Orange" "Berry Pear" "Peach Plum") do (
md !X!\!X!" "%%a
)

Works great for what I need. Appreciate the help and education.


Report •

Ask Question