Computing.Net > Forums > Disk Operating System > Creating Directories

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Creating Directories

Reply to Message Icon

Name: Raj Katyal
Date: April 24, 2003 at 15:14:14 Pacific
OS: Windows XP
CPU/Ram: Pentium 4/256
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Adam
Date: April 24, 2003 at 15:58:57 Pacific
Reply:

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.


0

Response Number 2
Name: Madhavan
Date: April 24, 2003 at 20:03:13 Pacific
Reply:

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 2004

Put 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


0

Response Number 3
Name: raj katyal
Date: April 25, 2003 at 08:41:42 Pacific
Reply:

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>test

K:\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


0

Response Number 4
Name: Secret_Doom
Date: April 26, 2003 at 14:45:05 Pacific
Reply:

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

________________________________________________________


0

Response Number 5
Name: Raj Katyal
Date: April 28, 2003 at 08:02:45 Pacific
Reply:

Thanks a lot that worked beautifully.

Appreciate all your help!


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Appending Datestamp to Fi... Tandy 1400 Laptop



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Creating Directories

create directory? www.computing.net/answers/dos/create-directory/3667.html

create directories and put files in www.computing.net/answers/dos/create-directories-and-put-files-in/16513.html

Creating Directories question www.computing.net/answers/dos/creating-directories-question/13252.html