create multiple folders using folder/*/folder"

-1

I've been using this line to create multiple folders in different sub-folders using a wildcard:

FOR /d %A IN ("C:\users\me\desktop\test\*") do mkdir "%A\test3\"

My problem now is that I have to create multiple folders after the wildcard and only in an already existing folder called test2:

FOR /d %A IN ("C:\users\me\desktop\test\*\test2") do mkdir "%A\test3\"

How do I get this to work?

Lorent Dezco

Posted 2019-10-15T08:57:13.080

Reputation: 1

Answers

1

Wildcards can only be used in the last element of a path, so you need to do this:

for /D %A in ("%UserProfile%\Desktop\test*") do if exist "%~A\test2\" mkdir "%~A\test2\test3"

aschipfl

Posted 2019-10-15T08:57:13.080

Reputation: 553

1You'll need an additional if exist otherwise mkdir will just create test2 everywhere. – user1686 – 2019-10-15T11:26:27.573

You're right, @grawity, thanks for the hint! I updated my answer accordingly... – aschipfl – 2019-10-15T14:41:20.337