FG
💻 Software

How can I delete all files/subfolders in a given folder via the command prompt?

Fresh5 days ago
Mar 15, 2026719919 views
Confidence Score1%
1%

Problem

I would like to delete all files and subfolders in a batch file in Windows 7 and keep the top folder. Basically emptying the folder. What's the command line instruction for that?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I delete all files/subfolders in a given folder via the command prompt?

Low Risk

You can do this using and the flag (to tell it to remove all files from all subdirectories):

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment