del command (Windows / CMD)
What it does
Permanently delete one or more files. Searches for the del command cmd safely usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Permanently delete one or more files.
Syntax
del [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
Common options
| Flag / option | Meaning |
|---|---|
| /P | Prompt before deleting each file. |
| /F | Force deletion of read-only files. |
| /S | Delete matches in all subdirectories. |
| /Q | Use quiet mode for global wildcards. |
Practical examples
Delete file
del obsolete.txt
Permanently removes one file.
Confirm wildcard
del /P *.tmp
Prompts for each temporary file.
Delete nested logs
del /S /Q C:\Temp\*.log
Deletes matching logs below Temp.
Linux ↔ Windows equivalent
Closest match: rm (Linux / bash / sh / zsh). Remove files and directory trees permanently.
Common mistakes
- Danger: `/S /Q` with a broad wildcard can permanently delete many files without prompts; run dir with the same pattern first.
- Expecting deleted files to go to the Recycle Bin.
- Using del for directories; use rmdir instead.
Related commands
- rmdirRemove an empty directory or an entire directory tree.
- Remove-ItemDelete provider items such as files, directories, registry keys, and variables.
- rmRemove files and directory trees permanently.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
FAQ
What does del do in Command Prompt?
Permanently delete one or more files.
How do I run del in CMD?
Open Command Prompt and follow `del [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names`; quote paths containing spaces.
What is a practical del example in CMD?
Try `del obsolete.txt` — Permanently removes one file.
Can del be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.