Windows CMDInteractive Lab
File Managementdel

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

Rojan Acharya··Updated Apr 17, 2026
Share

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]]
SwitchDescription
/PPrompt before each deletion
/FForce delete read-only files
/SDelete matching files in subdirectories
/QQuiet mode, no prompts
/AAttribute-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 DIR before DEL.
  • Start with /P in 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

CommandPurpose
DEL file.txtDelete single file
DEL *.tmpDelete by extension
DEL /P *.logPrompted delete
DEL /F /Q *.bakForce quiet delete
DEL /S /Q C:\Temp\*.tmpRecursive 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.