Skip to main content

Command referencedel

del command (Windows / CMD)

WindowsCMDfilebeginnerDestructive — use carefully

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 / optionMeaning
/PPrompt before deleting each file.
/FForce deletion of read-only files.
/SDelete matches in all subdirectories.
/QUse 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.

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.