2

Is there a way I can do this in ms powershell? (w/o scripting)

mkdir a\b\c\d{a,b,c,d}

I want to make multiple subdirectories at once just like in bash but when i run it in powershell it gives me this error :

At line:1 char:17
+ mkdir a\b\c\d{a,b,c,d}
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingArgument**

I had tried all of the following:

mkdir a\b\c\d\{a b c d}
mkdir a\b\c\d\a,b,c,d}
mkdir a\b\c\d\[a,b,c,d]

1 Answer 1

3

Try this:

"a","b","c","d" | % { mkdir "a\b\c\d\$_" }

or

echo a,b,c,d | % { mkdir "a\b\c\d\$_" }

See: Powershell equivalent of Bash Brace Expansion for generating lists/arrays

Sign up to request clarification or add additional context in comments.

1 Comment

This definitely serves my purpose, now I understand why i'm doing it wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.