FG
💻 Software

How do I delete directory trees via batch file on Windows 7?

Fresh5 days ago
Mar 15, 2026125553 views
Confidence Score0%
0%

Problem

I want to delete the whole content of a specified folder on Windows 7 via batch file. My problem is, that 'del' or 'erase' only deletes the files, not the folders and 'rmdir' or 'rd' always deletes the specified folder with its content, but I only want to delete the content, not the folder itself. …

Error Output

rmdir /S /Q "C:\Share\*"

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I delete directory trees via batch file on Windows 7?

Low Risk

Your batch file will need to run two commands, one to clear out the files then one to remove the child directories. I've assumed the directory you want to remove is The batch file should look something like this: will recursively search through the …

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment