How to create a folder or sub directory using Windows Powershell

In Windows PowerShell, Directory can be created using the New-Item cmdlet

Syntax:  New-Item -ItemType directory -Path <CompletePath> 

Example:
i) New-Item -ItemType directory -Path C:\Development
This will create directory named Development inside the C drive.

ii) New-Item -ItemType directory -Path C:\Development\FileTransferProject\Output
This will create a directory named Output insidide the FileTransferProject folder, here if the sub directory that is FileTransferProject was not present than FileTransferProject folder will also be created and then the folder Output will be created

Note - If the Directory already exists, then PowerShell will exit without creating the directory.

No comments: