How to delete folder with subfolders using command line on Windows 10

It's possible to delete a folder with subfolders and files with Command Prompt and PowerShell, and here's how.

Recursively delete folders commands
Recursively delete folders commands / Image: Mauro Huculak
  • To delete folders and subfolders on Windows 10, open Command Prompt (admin) and run the “rmdir” command, for example, “rmdir /s C:\files”.
  • You can also open PowerShell (admin) and run the “Remove-Item” command, for example, “Remove-Item -Recurse -Force C:\files”.

On Windows 10, you can delete a folder with subfolders and files using commands to get rid of unnecessary contents and maintain storage organized, but you need to know the correct tool for the job, and in this guide, I will show you how. 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 since the tool only deals with files, not folders.

The tool you need to use will depend on the command console if you want to delete folders with content inside them. If you use Command Prompt, “rmdir” (short for remove directory) provides the capability to delete folders along with their subfolders and files recursively. On the other hand, PowerShell users can rely on the “Remove-Item” cmdlet to achieve similar results, offering a powerful alternative for folder deletion operations.

In this guide, I will teach you two ways to delete subfolders with Command Prompt and PowerShell on Windows 10.

Warning: Before proceeding with deleting any files or folders, especially when using commands, it’s important to double-check the paths and names of the directories you intend to delete since these operations are irreversible and can result in the loss of valuable data if executed incorrectly. Consider backing up important data before performing bulk deletions. You have been warned.

Delete folders with subfolders from Command Prompt

To delete a folder with subfolders with Command Prompt on Windows 10, use these steps:

  1. Open Start on Windows 10.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. 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

    Delete empty folder

  4. 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

    Delete folder with content

  5. 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

    Delete folder with subfolders quietly

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. You can also use the short version of the rmdir using rd.

Delete folders with subfolders from PowerShell

To recursively delete an entire folder with PowerShell on Windows 10, use these steps:

  1. Open Start.

  2. Search for PowerShell, right-click the top result, and select the Run as administrator option.

  3. 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

    PowerShell delete folder command with confirmation

  4. 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

    PowerShell recursively delete folder

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 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.

What command do you prefer? Share your experience or any additional tips in the comments section.

Update February 6, 2024: This guide has been updated to ensure accuracy and reflect some changes.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 15 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 21 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].