Search code examples
powershellmkdir

Equivalent for linux mkdir {fileA,fileB} in PowerShell


I'm just curios. Is there an equivalent for PowerShell that behaves equally to the liunx command listed in the title, i.e.

mkdir {folderA, folderB}

?

-- edit

the command listed above creates the folders "folderA" and "folderB" (just saw that I wrote file previously. Sorry, my fault) in the current working directory.


Solution

  • The mkdir command in PowerShell is a wrapper for the New-Item command. If you want to create multiple folders with a single command, then run:

    mkdir c:\test,c:\test2;
    

    Effectively, because of positional parameters in PowerShell, this passes the array c:\test,c:\test2 to the -Path parameter of the New-Item command.