replicating a set of subfolders

Microsoft Windows xp professional w/serv...
September 11, 2009 at 10:59:56
Specs: Windows XP SP3, Core2Duo 2GHz / 2GB RAM
The company I work for has created a folder for each of the clients we have (folder name = client name). Recently in a staff meeting we decided that to standardize on organization, the client folders (350 of them already there) should all have 7 standard subfolders within each one, for example- Contracts, Correspondence, Projects, etc. Creating these 7 subfolders inside any NEW client folders is easy, but we want to know if there is a way to auto-create these 7 standard subfolders inside the 350 existing client folders, so someone doesn’t have to break their arm off trying to do it manually.

Many of these client folder names have commas and spaces, which has been throwing off attempts trying to use the FOR command.

Any suggestions?


See More: replicating a set of subfolders

Report •


#1
September 11, 2009 at 11:03:35
Let's see your FOR command.

Report •

#2
September 11, 2009 at 11:22:16
I have been trying with the "for /f %1 in (myfile.txt) do ...", which as I understand it will perform the command after "do" to each line in the "myfile.txt".

So first I used a "dir..." command to create a text file with the names of the client folders, each one on its own line. Saved it as list.txt.

Next I tried this -
for /f %1 in (list.txt) do md %1\contracts

What I found was 2 problems, 1- it kept recursively creating subfolders deeper and deeper until it errored out, and 2- it treated the comma and space in each line of list.txt as a delimiter, so it actually didn't create the subfolder "contracts" where I wanted it to.

I have focused the efforts first on just trying to get the command to recognize each entire line in the list.txt file as a single entity, but have been coming up short. So that meant changing up the command to something simpler, say just echoing back the info, like
for /f %i in (list.txt) do @echo %i
I've experimented with single and double quotes, etc, using the delims option, but nothing seems to work right to echo back each full line in the list.txt. Once it will echo back the full line, then maybe I can figure out a command/ set of commands to pass along to it.

Make any sense?


Report •

#3
September 11, 2009 at 11:25:45
for /f "delims=" %i in (list.txt) do @echo %i

EDIT: Note: When you use MD, make sure you use double quotes.
ie: md "%i\contacts"


Report •

Related Solutions

#4
September 11, 2009 at 11:38:48
fan-friggin-tastic! ok, so that will echo back each full line.

Next step is to pass along a command after "do" that creates the set of subfolders. The command...
for /f "delims=" %i in (list.txt) do md %i\projects
does not work.

Is it possible to have the "do" section launch another batch file (that has lines in it to create each subfolder), but then have it come back and continue to process each line in the list.txt file in the same way?


Report •

#5
September 11, 2009 at 11:40:38
See the edit in my previous post.

Report •

#6
September 11, 2009 at 11:51:27
Razor2.3, you are the BEST!! If you were around, I'd buy you a couple of rounds...

TGIF, thanks again.


Report •


Ask Question