4iT IT Support Sydney | Your Reliable Sydney IT Support Partner

Knowledge Base

How to Delete a Folder from the Command Prompt in Windows

To delete a folder from the command prompt in Windows, use rmdir /s /q "C:\path\to\folder". The /s switch removes the folder and everything inside it, and /q does it quietly without asking you to confirm each item. The command rd is an alias for rmdir, so the two are interchangeable.

Windows command prompt window open showing a file path

Key facts

  • Delete a folder and its contents with rmdir /s /q "path" (or the shorter rd /s /q).
  • /s includes all subfolders and files; /q suppresses the confirmation prompt.
  • Command prompt deletions skip the Recycle Bin, so they are permanent.
  • For stubborn files, del /f /s /q forces deletion of read-only and hidden files first.
  • PowerShell’s equivalent is Remove-Item -Recurse -Force "path".

How do you delete a folder and everything in it?

The rmdir command with the /s and /q switches removes a folder and its entire contents in one step. Open Command Prompt, then run the command with the full path in quotes if it contains spaces:

rmdir /s /q "C:\Users\Public\Old Project"

Without /s, rmdir only removes empty folders and refuses to touch anything with files inside. Without /q, it asks “Are you sure (Y/N)?” for the removal. Most people want both switches together so the folder simply goes.

What do you do about stubborn folders that will not delete?

When a folder will not delete, the cause is almost always a file inside it that is read-only, hidden, or in use. Clear the read-only and hidden files first with del /f /s /q "C:\path\to\folder\*.*", which force-deletes every file regardless of attribute, then run rmdir /s /q on the now-empty structure. If the deletion still fails with “access denied” or “the process cannot access the file”, something has the file open; close the application using it, or the issue may need administrator rights. Running the command prompt as administrator resolves a lot of these.

Should you use Command Prompt or PowerShell?

Both work, so it comes down to what you are comfortable with and what else you are doing. Command Prompt with rmdir is quick and familiar for a one-off deletion. PowerShell’s Remove-Item -Recurse -Force "C:\path\to\folder" does the same job and fits better when the deletion is part of a larger script, because PowerShell handles paths, error checking, and conditions more cleanly. For a single folder, either is fine.

Frequently asked questions

Does deleting a folder from Command Prompt send it to the Recycle Bin?

No. Files and folders removed with rmdir or del are deleted immediately and do not pass through the Recycle Bin. There is no easy undo, so double-check the path before you run the command, particularly when using the quiet switch that skips confirmation.

How do I delete a folder that says “access denied”?

Access denied usually means you lack permission or a file is in use. Open Command Prompt as administrator and try again, and close any program that might have a file open in that folder. If the folder is owned by another account or the system, you may also need to take ownership of it before Windows will let you delete it.

What is the difference between rmdir and del?

They target different things. del removes files but cannot remove folders. rmdir (or rd) removes folders, and with the /s switch it removes the files inside them too. For force-clearing awkward files before removing a folder, del with /f is the tool; for the folder itself, rmdir is the one.

Quick command-line fixes are fine in a pinch, but a business running on undocumented manual workarounds is one staff change away from a problem. If that sounds familiar, happy to help get the basics properly managed.

Brett Muscio

About the author

Brett Muscio is the Director of 4iT Support Pty Ltd, a managed services provider based in Castle Hill, NSW. He works with SME clients across Sydney, Melbourne, and Brisbane on managed IT support, automation, and Windows administration, with on-site support across the Sydney metro area and remote delivery nationally. Connect on LinkedIn.

 

Scroll to Top