[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

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.
0
wiafelice
Asked:
wiafelice
  • 4
  • 3
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
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
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
TEST FIRST by using this:

FOR /F "Tokens=1" %a in ('DIR /ad /b') Do @ECHO MD %a\2006
0
 
wiafeliceAuthor Commented:
Perfect answer.  Is there any documentation on where you got that syntax from?  I would love to mess around with those paramaters.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Type FOR /? at a command prompt.

Also, review:
www.robvanderwoude.com - spefically the Batch File section.
0
 
wiafeliceAuthor Commented:
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


0
 
wiafeliceAuthor Commented:
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
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
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.
0
 
raamaya2Commented:
This Has also Helped me very much. Thank Everyone for all of the input.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now