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
  • 162,382

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
  • 162,382