delDEL Command in Windows: Safe Deletion Guide
Learn how to use the DEL command in Windows safely with syntax, examples, wildcard deletion, troubleshooting, and best practices before removal.
The DEL command deletes files from Command Prompt. It is fast and powerful, but mistakes are costly because deleted files may bypass normal GUI confirmation workflows. Always verify targets with DIR before running destructive patterns.
What Is DEL Command?
DEL removes one or more files using exact names or wildcard patterns. It does not delete directories; use rmdir for folders.
Syntax
DEL [path\]filename [/P] [/F] [/S] [/Q] [/A[:attributes]]
| Switch | Description |
|---|---|
/P | Prompt before each deletion |
/F | Force delete read-only files |
/S | Delete matching files in subdirectories |
/Q | Quiet mode, no prompts |
/A | Attribute-based selection |
Examples
DEL report.txt
DEL *.tmp
DEL /P *.log
DEL /F /Q *.bak
DEL /S /Q C:\Temp\*.tmp
Common Use Cases
- Cleanup temporary files.
- Remove generated artifacts in scripts.
- Delete stale logs from automation jobs.
- Force-delete read-only leftovers.
Tips and Best Practices
- Preview with
DIRbeforeDEL. - Start with
/Pin unfamiliar paths. - Avoid broad wildcards in root directories.
- Prefer explicit paths in scheduled scripts.
Troubleshooting Common Issues
Access denied
Use /F and run elevated CMD if required.
Files not deleted recursively
Add /S and verify wildcard pattern.
Accidentally matched wrong files
Run DIR pattern first to preview.
Read-only files remain
Use /F and ensure no process lock.
Related Commands
Frequently Asked Questions
Does DEL delete folders?
No, use rmdir for directories.
How do I force delete read-only files?
Use DEL /F filename.
How do I delete without prompts?
Use /Q.
How do I delete recursively?
Use /S.
Is DEL reversible?
Not reliably; treat it as destructive.
Can I use wildcards?
Yes, such as *.tmp.
What is safer: DEL or GUI delete?
GUI delete is usually safer for casual use.
Should I run DIR before DEL?
Yes, always.
Quick Reference Card
| Command | Purpose |
|---|---|
DEL file.txt | Delete single file |
DEL *.tmp | Delete by extension |
DEL /P *.log | Prompted delete |
DEL /F /Q *.bak | Force quiet delete |
DEL /S /Q C:\Temp\*.tmp | Recursive cleanup |
CTA
Practice safe deletion workflows in the Windows Command Simulator and review other file tools in Commands Reference.
Summary
DEL is powerful for automation and cleanup, but safety comes first. Preview with DIR, use explicit paths, and apply /P or /Q intentionally based on risk.