Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have been assigned with a task, that requires a batch file. I really don't have much knowledge:
Here is the scenerio:I have a Directory called Client Files.
Underneath the Client Files directory there are about 4000 directories with Client Names.
Underneath the each of the 4000 client names directories I need to create a folder called 2004.

You could go in each folder and make the directory like md 2004 or make a batch like
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
cd "directory/subdir/" md 2004\
Etc.

You need two batch files:
In the first, put this command:
for %%i in (*.*) do call second.bat %%i
In the second batch file (called second.bat) enter this:
cd %1
md 2004Put both the batch files in the directory where you have the 4000 subdirs and execute the first batch file.
_____________________________________________
The Bleeding Edge - Hardware, software, operating systems, programming and drivers.
http://bleeding.vze.com

Hi Madhavan,
I tried using your suggestion but it did not quite work. I am not sure why.
This is what i got
K:\Client Files>testK:\Client Files>for %i in (*.*) do call second.bat %i
K:\Client Files>call second.bat second.bat
K:\Client Files>cd second.bat
The directory name is invalid.K:\Client Files>md 2004
K:\Client Files>call second.bat test.bat
K:\Client Files>cd test.bat
The directory name is invalid.K:\Client Files>md 2004
A subdirectory or file 2004 already exists.The above batch file creates a directory 2004 under the directory Client files.
I need to create the sub-directory 2004 under each of the 4000 folders.Thanks

First of all, you do not need two batch files for that (usually you never need two of them, you can merge'em into a single one).
Besides, that method Madhavan described is not proper, not without various modifications. Use this, instead:
@echo off
for /D %%? in ("C:\Client Files\*.*") do (
if not exist "%%?\2004\nul" md "%%?\2004"
)That will only work on NT systems (Windows NT,2K,XP).
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br________________________________________________________

![]() |
Appending Datestamp to Fi...
|
Tandy 1400 Laptop
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |