How create/delete a directory in MS Windows?


Making directories or deleting them is one of the most basic tasks that we do on our computers. In a Windows system, there are multiple ways in which you can create or delete a directory. You can use Windows GUI, shortcut keys, or a command line to create a folder.

Using the Windows command line to create or delete a directory is faster especially when you are creating or deleting multiple directories.

In this article, we will show you how to create or delete a directory using Windows command prompt or PowerShell.

How to create a directory in Windows OS

As discussed earlier there are multiple methods to create a folder in Windows OS some of them are discussed here. You can use one of the given methods to create a directory on your system.

How to create a folder using Windows GUI

The easiest way is to move to the location where you want to create a folder and then right-click on the screen go to New and then click on Folder now enter the name of the folder next press enter your folder will be created.

Please note that while creating a folder at some places such as inside the drive where Windows is installed you may need to have the administrator’s permission.

Creating a new folder using shortcut keys

You can use a combination of keys to create a folder on your pc this is one of the fastest methods to create a folder in Windows. Follow the given steps to create a folder using shortcut keys –

  • First, move to the location where you want to create a folder
  • Next press Ctrl+Shift+N now a folder icon will appear on your screen
  • Enter the desired name of the folder and then press the enter key

Creating directory by using mkdir or md command

Sometimes you may need to create or delete a directory using the command line. This method of creating a folder is fast and very useful if you want to create multiple folders.

Follow the given steps to create a directory using mkdir or md command –

  • Press the Start button and then search for cmd or PowerShell, click on the icon to start the application that appears on your screen. You can also open the application by pressing Win+R and then searching cmd or Powershell.
  • You can see the list of directories by using the dir command, Now navigate to the location where you want to create a directory
  • Now use the mkdir or md command followed by the directory or folder name that you want to create
mkdir dir1

The above command will create a directory dir1 in your current working directory.

If you want to create multiple directories let’s say dir1, dir2, dir3 then use the following command in your command prompt –

mkdir dir1 dir2 dir3

This will create three directories in your current working directory.

How to delete a directory on Windows

In different ways, you can remove a directory from your Windows system. The simplest way of removing a directory is first to right-click on the directory or folder and then click on the delete option.

Read this section ahead if you want to remove the directory using the command line.

Removing a directory by using rmdir command

To delete a directory in Windows you can use either rmdir or rd command. Both commands work in the same way. The syntax of rmdir or rd command is given below –

rmdir [/S] [/Q] <directory_name>

OR

rd [/S] [/Q] <directory_name>

Where,

/S – Use to remove all the nested files and subdirectories including the directory itself

/Q – This is the quiet mode, do not prompt for confirmation that it is deleting directories or files with /S

Deleting an empty directory

If you want to delete an empty directory you need not use any command-line switch. Simply use the rmdir or rd command followed by directory name and press enter.

rmdir dir

Please note that directory dir is an empty directory.

Removing a directory that contains files and directories

To delete a file or folder which contains files or directories in it you need to use /S and /Q with rmdir command. If you avoid using /S it will display a message saying “The directory is not empty”.

Now to delete the folder using cmd which contains files and directories use –

rmdir /S /Q dir

Conclusion

So here we discussed how to create or remove directories in Microsoft Windows operating system. Now for any queries or feedback please write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.