Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Windows XP Windows XP
Search Search
Search for:
Tech Support Guy > > >

Help with Batch File for creating subfolders


(!)

fenningenari's Avatar
fenningenari fenningenari is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: May 2005
Experience: Beginner
29-May-2005, 01:43 PM #1
Help with Batch File for creating subfolders
Hello,
I am trying to write a batch file that will create subfolders based on the name of the parent folder. So if the folder that I am working in is named "dg2001-10-19" then I want the batch file to create 3 subfolders named "dg2001-10-19 - WTA", "dg2001-10-19 - BHMM" and "dg2001-10-19 - files". In the other folders that I am working in I want it to work the same way - for a folder named "disc" it would create "disc - WTA", "disc - BHMM" and "disc - files" and place them in the disc folder.

If anyone can help me I would really appreciate it. I realize that this is probably a simple thing but I am not very familiar with programming or batch files. Thank you very much for your help.
JohnWill's Avatar
Computer Specs
Retired Moderator with 106,412 posts.
 
Join Date: Oct 2002
Location: South Eastern PA, USA
29-May-2005, 08:36 PM #2
If you're in the folder and you run the batch there, try this:

<content of <BUILDSUB.BAT>
MD WTA
MD BHMM
MD files

This should work in any folder to create those three sub-folders.
fenningenari's Avatar
fenningenari fenningenari is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: May 2005
Experience: Beginner
30-May-2005, 12:18 PM #3
Quote:
Originally Posted by JohnWill
If you're in the folder and you run the batch there, try this:

<content of <BUILDSUB.BAT>
MD WTA
MD BHMM
MD files

This should work in any folder to create those three sub-folders.

Thanks for the reply, I appreciate it. That won't work though. I don't want to make a folder named "WTA" I want to make a folder named the same thing as the parent folder except with " - WTA" added to the end of it. For instance, if the folder that I am in is named "jg1980-10-01" then I want for the subfolders to be named "jg1980-10-01 - WTA" and "jg1980-10-01 - BHMM" and "jg1980-10-01 - files". See what I mean?

I don't know how to tell the batch file that part of the name of the folder should be exactly the same as the folder that I am currently in, but the rest of the folder name should be a constant, like " - WTA".

Again, thank you for your reply. Any ideas?
JohnWill's Avatar
Computer Specs
Retired Moderator with 106,412 posts.
 
Join Date: Oct 2002
Location: South Eastern PA, USA
30-May-2005, 08:47 PM #4
Well, you weren't all that clear, so I guessed.

I'd probably use a batch enhancer to do this trick. if you're running this under Windows, you can do all of this and more with AutoIt.
Squashman's Avatar
Trusted Advisor with 19,633 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
30-May-2005, 09:47 PM #5
I can script this so easily in Linux shell script. I always have a hard time converting that over into batch files.
pr0t3st's Avatar
pr0t3st pr0t3st is offline
Senior Member with 457 posts.
 
Join Date: Apr 2005
Location: FUN CITY
Experience: Advanced
30-May-2005, 11:12 PM #6
Here try this batch script:

Quote:
@ECHO OFF

:LOOP
CLS
ECHO.
ECHO // S T E P 1 //
SET DRPATH=
ECHO.
ECHO.
ECHO Specify full [Drive]:[Path] to the parent folder you wish to work
ECHO with... Non 8-dot-3 names may be used; DO NOT enclose the path in
ECHO "quotes" even if it contain spaces !!
ECHO.
ECHO IF the working folder is called "My Data", located at the root of
ECHO C:, just enter "C:\My Data" (NO quotes or trailing slash " \ ").
ECHO.
ECHO IF located in a sub directory on a network share or drive, proper
ECHO format = \\Share Name\any subdir\My Data
ECHO.
ECHO.
SET /P DRPATH=Specify Target Path:

IF NOT EXIST "%DRPATH%" GOTO LOOP

CLS
ECHO.
ECHO // S T E P 2 //
SET PARENT=
ECHO.
ECHO.
ECHO Next, enter the actual folder name below; again, long folder names
ECHO may be used. For example, if you entered My Data in Step 1, do the
ECHO SAME here without specifying the full path.
ECHO.
ECHO RIGHT = Data Dir , My Data , etc ; WRONG = "Data Dir" , C:\My Data
ECHO.
ECHO.
SET /P PARENT=Parent Folder Name:

MD "%DRPATH%\%PARENT% - WTA"
MD "%DRPATH%\%PARENT% - BHMM"
MD "%DRPATH%\%PARENT% - FILES"
The best I could come up with ...
fenningenari's Avatar
fenningenari fenningenari is offline
Junior Member with 3 posts.
THREAD STARTER
 
Join Date: May 2005
Experience: Beginner
30-May-2005, 11:21 PM #7
Thanks for the help guys. I got it working now. I appreciate all your help.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑