New-Item
Create a file or folder
New-Item -Path .\docs -ItemType Directory
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: New-Item
Creates files and folders. -ItemType Directory makes a folder. -ItemType File makes a file. -Force creates missing parents for files in some versions; prefer creating the folder first.
Try this
New-Item -Path .\docs\readme.txt -ItemType File
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | mkdir -p docs |
| cmd.exe | mkdir docs |
More in From bash and From cmd.