You can delete a folder with subfolders and files using commands, but you need to know the correct tool for the job. On Windows 10, when you have to remove a file or folder with a command terminal, the first tool that comes to mind is the “del” command, but you will quickly find out that it won’t work to delete folders with subfolders recursively because the tool only deals with files.
The tool you need to use will depend on the command console if you want to delete folders with content inside of them. If you use Command Prompt, “rmdir” (remove directory) is the tool you want to use to delete folders recursively. On the other hand, if you are using PowerShell, “Remove-Item” is the cmdlet that will do the job.
This guide will teach you two ways to delete subfolders with Command Prompt and PowerShell on Windows 10.
Delete folders with subfolders from Command Prompt
To delete a folder with subfolders with a command on Windows 10, use these steps:
-
Open Start on Windows 10.
-
Search for Command Prompt, right-click the top result, and select the Run as administrator option.
-
Type the following command to delete an empty folder and press Enter:
rmdir PATH\TO\FOLDER-NAME
In the command, replace “PATH\TO\FOLDER-NAME” with the folder path and the folder name you want to delete. This example removes the “files” folder:
rmdir C:\files
-
Type the following command to delete the folder and subfolders with contents and press Enter:
rmdir /s PATH\TO\FOLDER-NAME
This example removes the “files” folder, subfolders, and files:
rmdir /s C:\files
-
Type the following command to delete a folder with content recursively without a confirmation prompt and press Enter:
rmdir /s /q PATH\TO\FOLDER-NAME
This example removes the “files” folder, subfolders, and files without prompting for confirmation:
rmdir /s /q C:\files
Once you complete the steps, the command will delete the folders with subfolders and files from Windows 10.
The /s
option deletes the folder and its content in the above command, but it prompts confirmation. The /q
option ignores the prompt and deletes the folder recursively.
Delete folders with subfolders from PowerShell
To recursively delete an entire folder with a PowerShell command on Windows 10, use these steps:
-
Open Start.
-
Search for PowerShell, right-click the top result, and select the Run as administrator option.
-
Type the following command to delete an empty folder and press Enter:
Remove-Item PATH\TO\FOLDER-NAME
In the command, replace “PATH\TO\FOLDER-NAME” with the folder path and the folder name you want to delete. This example removes the “files” folder:
Remove-Item C:\files
-
Type the following command to delete an empty folder and press Enter:
Remove-Item -Recurse -Force PATH\TO\FOLDER-NAME
This example removes the “files” folder:
Remove-Item -Recurse -Force C:\files
After you complete the steps, the command will delete the folder on Windows 10 and its contents with or without a prompt, depending on the command you choose.
The -Recurse
option tells the command that you want to delete the folder and its contents without prompt confirmation. The -Force
option is not required but allows for erasing special items, including read-only or hidden files.