CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Windows – How to manage directories from Command Prompt?

Directories are logical groups in the File System in Windows Operating System useful to holds the files and folders. Content of the directories means, the list of files and directories the directory holds.

Windows provides list of commands to manage the directories from the command prompt. We will discuss those commands through this Article.

Create the Directory – MKDIR or MD command

To create a directory from Windows command prompt, we use either MKDIR or MD command. You must pass the path of the directory to create as an argument. Otherwise, Windows will throw below message.

The syntax of the command is incorrect.

The path may be relative or absolute path. Below command is used to create a folder Personal.

C:\> mkdir Personal

It creates the folder if it is NOT exists already. Otherwise, Windows will show the below message.

A subdirectory or file Personal already exists.

Change Directory – CHDIR or CD command

To enter into the directory from Command Prompt, we use the command CHDIR or CD.  The path of the directory has to be passed as an argument to these commands. Below is the command to enter into the directory “Personal”.

C:\> chdir Personal
C:\Personal>

Upon success, you will see the command prompt shows the directory path where you are currently. If the directory path doesn’t exists, Windows will show the below message.

The system cannot find the path specified.

Remove Directory – RMDIR or RD command

To remove the directory, you need to use either RMDIR or RD command. You must pass the path of the directory to be removed. Below is the command to remove the directory “Personal” from the System.

C:\> rmdir Personal

The command removes the directory from the System, if it is empty. Otherwise, Windows shows below message and NOT allows you to delete the folder.

The directory is not empty.

Doesn’t it possible to remove the directory if it is NOT empty? No, we can. These commands provides a switch to do this; which is “/s” to allow to remove the non-empty directory. When attempt, it will prompt you to remove the directory. Upon your input, these commands removes the folder from the System.

Below command is useful to remove the non-empty folder.

C:\> rmdir Personal /s
Personal, Are you sure (Y/N)?

Be cautious when you are removing the folder as you will lose the information if you accidentally deletes the folders.

Be on learning path always!

// Malin

Windows – How to manage directories from Command Prompt?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top