How to delete folder with subfolders using commands on Windows 11

You can use Command Prompt and PowerShell to delete a folder with subfolders recursively, and here's how.

Windows 11 delete folder with subfolders
Windows 11 delete folder with subfolders

On Windows 11, you can use the del command with the terminal to quickly delete a file or folder. However, you can’t use it to delete folders recursively since the tool is designed for files.

If you have to remove files and subfolders from a folder, you must use different tools. For example, you can use the rmdir (remove directory) a tool with Command Prompt to delete folders recursively, or you can use the Remove-Item cmdlet on PowerShell.

This guide will teach you two ways to quickly delete folders with Command Prompt and PowerShell subfolders.

Delete folders with subfolders with Command Prompt

To remove a subfolder from a folder with commands on Windows 11, use these steps:

  1. Open Start on Windows 11.

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

  3. Type the following command to remove 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 to delete. This example removes the “files” folder:

    rmdir C:\files

    Command Prompt delete single folder

  4. Type the following command to delete folders and subfolders with contents on Windows 11 and press Enter:

    rmdir /s PATH\TO\FOLDER-NAME

    This example removes the “files” folder, subfolders, and files:

    rmdir /s C:\files

    Command Prompt delete subfolders from folder

  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

    Command Prompt remove subfolders recursively no prompt

Once you complete the steps, the command will remove a subfolder from a folder and files from Windows 11.

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 on PowerShell

To recursively delete an entire folder (with subfolders) on PowerShell, 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 PATHTOFOLDER-NAME with the folder path and the folder name to delete. This example removes the “files” folder:

    Remove-Item C:\files

    PowerShell delete single folder

  4. Type the following command to delete a folder with subfolders on Windows 11 and press Enter:

    Remove-Item -Recurse -Force PATH\TO\FOLDER-NAME

    This example removes the “files” folder:

    Remove-Item -Recurse -Force C:\files

    PowerShell delete folder with subfolders

After you complete the steps, the command will remove the folder and its contents with or without a prompt, depending on the command.

The -Recurse option deletes the folder and its contents without prompt confirmation. The -Force option erases special items, including read-only or hidden files, but it’s not required.

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