Link to home
Start Free TrialLog in
Avatar of wiafelice
wiafelice

asked on

batch file/command to create a folder in multiple folders

I need to create a folder inside of  2600 folders.  The folder that needs to be created will be the same name. Probably the year- \2006.  The 2600 folders are at the same lvl so they all have different names.

\clients\abc\2006
---------\bcd\2006
----------\cdf\2006
----------\def\2006

I was hoping there was an easy way to copy or move a folder into multiple folders but it does not seem to work when I copy the folder to clipboard, then ctrl-a to select all the folders under clients and then paste.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Use this ONE command on the command line, NOT in a batch file (as is, it won't work in a batch file).

FOR /F "Tokens=1" %a in ('DIR /ad /b') Do MD %a\2006
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wiafelice
wiafelice

ASKER

Perfect answer.  Is there any documentation on where you got that syntax from?  I would love to mess around with those paramaters.
Type FOR /? at a command prompt.

Also, review:
www.robvanderwoude.com - spefically the Batch File section.
Thanks for the fast replies btw,

but after working with this on a test folder I found out this does not work with folders that are long filesanmes.  The folders i need to add the \2006 folder to can be any number of words/numbers/spaces.  After looking at the syntax I'm not sure where to add the parameter.  I assume it is part of the tokens parameter.

Any info would be great


after more research/testing it looks like it works with replacing the tokens=1 to tokens=*  again I am just testing this on a test folder with no problems.  I will get a solid backup before i try it on our live folder.

Thanks again for the help
Yes, * will work - and possibly better if you have any folders with spaces in them (I try to avoid creating folders with spaces and don't always remember to point that out.
This Has also Helped me very much. Thank Everyone for all of the input.