How to Delete Folder Using CMD?

Command Prompt and PowerShell allow you to delete folders and subfolders, here’s the complete guide on how to delete folder using CMD. It is possible to delete a folder with subfolders and files using a command prompt, but the right command is needed for it.

Using Windows 10, the del command is the first thing that comes to mind when removing a file or folder from a command prompt. The command does not work recursively when deleting folders with subfolders, since it deals only with files.

Command-line tools will differ depending on the terminal you are using if you want to delete folders with content inside. Recursive folder deletion can be accomplished by using rmdir (remove directory) in Command Prompt. Meanwhile, If you’re using PowerShell and want to remove folders then you need to proceed cmdlet command. Both tools have different structures and different commands.

Complete Guide on How to Delete Folder Using CMD?

In this article, we’ll learn in detail about How to Delete Folder Using CMD and PowerShell. We’ll discuss two methods to delete the folders through the command prompt.

Delete Folder & Subfolder Using CMD

Follow the given below steps to delete the folders and subfolders using CMD:

  • Search the “Command Prompt” from the search bar which will be seen at the left bottom corner with the start menu.
How to Delete Folder Using CMD
  • You can delete an empty folder by typing the following command: rmdir PATH\TO\FOLDER-NAME
  • Put the path to the folder and the name of the folder that you want to delete in PATH/TO/FOLDER-NAME.
  • To remove the “files” folder, follow this command: rmdir C:\files
  • You can delete folders and subfolders with contents by typing the following command: rmdir /s PATH\TO\FOLDER-NAME
  • You can remove all files, subfolders, and folders in the “files” folder using this command: rmdir /s C:\files
  • To recursively delete a folder with content, type the following command and press Enter: rmdir /s /q PATH\TO\FOLDER-NAME
  • Without prompting for confirmation, this command removes the “files” folder, subfolders, and files: rmdir /s /q C:\files

Your folders and subfolders will delete from Windows 10 after completing the steps. When the /s option is used in the above command, the folder and its contents are deleted, but a confirmation is required. By using the /q option, the folder is recursively deleted without prompting.

Delete Folder & Subfolder Using PowerShell

Follow the given below steps to delete the folders and subfolders using PowerShell:

  • Using the search bar, find PowerShell and choose Run as administrator from the top result.
  • You can delete an empty folder by typing the following command and pressing Enter: Remove-Item PATH\TO\FOLDER-NAME
  • Put the path and name of the folder that you want to delete in place of PATH/TO/FOLDER-NAME in the command.
  • The “files” folder will be removed with this command: Remove-Item C:\files
  • You can delete an empty folder by typing the following command and pressing Enter: Remove-Item -Recurse -Force PATH\TO\FOLDER-NAME
  • The “files” folder will be removed with this command: Remove-Item -Recurse -Force C:\files

With or without a prompt, the command will delete the folder and its contents after you complete the steps.

By specifying -Recurse, you tell the command that you want the folder and its contents to be deleted without prompting for confirmation. -Force can be used to erase read-only or hidden files, but it is not required.

Also, Read About: How to Clean Computer Memory?

Leave a Comment