3

So I want to create a folder inside a 2nd level of subfolders.

So if I follow other example given here:

FOR /d %A IN ("e:\corporate folder\*") DO mkdir "%A\2015"

And change it to:

FOR /d %A IN (C:\folder\*\folder1) DO mkdir "%A\Arq"

Do I need to add something more?

DavidPostill
  • 153,128
  • 77
  • 353
  • 394

1 Answers1

1

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

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • Thank you. Did not know that about the wildcards. Maybe what i'm trying to do can't by done this easy but let's see. 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" I now know this wouldn't work but is there any way of doing it? Thank you in advance. – João Santos Mar 10 '16 at 13:14
  • @JoãoSantos Answer updated – DavidPostill Mar 10 '16 at 13:28