Why can't I create a folder in c:\folder*\folder?
FOR /d %A IN (C:\folder\*\folder1) DO mkdir "%A\Arq"
You cannot have wildcards (*
) in the middle of a pathname.
Use the following command instead:
for /d %i in ("C:\folder\*") do mkdir "%i\folder1\Arq"
But I want to have a second wildcard
The problem is that I need to put another (*) along the way so for example:
for /d %A in ("C:\folder*") do mkdir "%A\folder1*\Arq"
Then you need a second for
loop.
Use the following command:
for /d %i in ("C:\folder*") do for /d %j in ("%i\folder1*") do mkdir "%j\Arq"
Further Reading
- An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
- for /d - Conditionally perform a command on several Directories/Folders.
- wildcards