To delete a file in Command Prompt, open the prompt, navigate to the folder containing the file (or use its full path), and run the del command followed by the file name. For example, del report.txt removes that file from the current directory. The command deletes files permanently without sending them to the Recycle Bin, so check the path and name carefully before you press Enter. This guide covers the exact steps, the options that make deletion safer or more forceful, and what to do when Windows refuses.
What You'll Need
- A Windows PC with Command Prompt available (it is built into Windows).
- The exact name and location of the file you want to delete.
- Basic awareness that
delbypasses the Recycle Bin — there is no undo. - Administrator rights if the file sits in a protected system folder.
Step-by-Step
- Open Command Prompt. Press the Windows key, type
cmd, and choose Command Prompt from the results. For files in protected locations, right-click and select Run as administrator. - Check where you are. The prompt shows your current directory, for example
C:\Users\YourName>. Thedelcommand acts on this folder unless you give a full path. - Navigate to the file's folder (optional). Use
cdfollowed by the path, such ascd Documents\Reports. If the path contains spaces, wrap it in quotes:cd "C:\My Documents\Reports". You can also skip this step and type the full path in the delete command. - List the folder contents to confirm the name. Type
dirand press Enter. This shows every file and folder in the current directory. Compare the name exactly — Windows filenames are not case-sensitive, but spelling and extensions must match. - Run the delete command. Type
del filename.extand press Enter. For example,del notes.txt. To delete from another location without navigating, use the full path:del "C:\Users\YourName\Documents\notes.txt". - Confirm the result. Run
diragain. If the file no longer appears, it is deleted. Command Prompt normally prints no message on success, which can be confusing — the absence of an error means it worked. - Use options only when needed. Add
/pto be asked for confirmation before each file is deleted (del /p notes.txt). Add/fto force deletion of read-only files (del /f notes.txt). Add/sto delete matching files in all subfolders, and/qto suppress confirmation prompts when used with/s. Combine carefully:del /s /q *.tmpremoves every .tmp file in the tree without asking. - Delete multiple files or use wildcards.
del *.txtdeletes all .txt files in the current folder.del *.*targets everything in the folder and will prompt for confirmation unless/qis added. Preview wildcard matches withdir *.txtfirst so you know exactly what will go. - Remove an empty folder (if that was the goal).
delremoves files, not folders. Usermdir(orrd) for an empty directory, andrmdir /s /qto remove a folder and its contents. This is a separate, more destructive command — double-check the path.
Common Mistakes
- Assuming the Recycle Bin is a safety net. Files deleted with
delfrom Command Prompt skip the Recycle Bin entirely. There is no built-in undo. - Forgetting the extension.
del noteswill not matchnotes.txtunless you type the extension or use a wildcard. - Running wildcards in the wrong folder.
del *.*inC:\Windowsor your user profile can remove far more than intended. Always rundirfirst. - Leaving out quotes around paths with spaces.
del C:\My Documents\notes.txtis read as two separate arguments and fails. Usedel "C:\My Documents\notes.txt". - Confusing
delwithrmdir.deldoes not remove folders; trying it produces an error or, with wildcards, unexpected results. - Ignoring the confirmation prompt. When
del *.*asks “Are you sure (Y/N)?”, pressing Y without reading is a common way to lose files.
Tips
- Use Tab completion: type the first few letters of a filename and press Tab to cycle through matching names, avoiding typos.
- Wrap any path containing spaces in double quotes, every time.
- Test destructive wildcards with
dirusing the same pattern before switching todel. - For important files, move them to a backup folder first with
move, then delete after confirming. - Remember that
del /ssearches subfolders too — a pattern that looks harmless at the top level can match files deep in the tree. - If you need a confirmation step for a batch of files,
/pis your friend; it asks before each deletion.
Troubleshooting
- “Access is denied.” The file may be read-only, in use by another program, or in a protected location. Close the program using it, try
del /f, or reopen Command Prompt as administrator. - “The system cannot find the file specified.” Check the spelling, the extension, and your current directory. Run
dirto see what is actually there, and confirm you are in the right folder withcd. - “The process cannot access the file because it is being used by another process.” A program still has the file open. Close it, or restart the PC and try again.
- Nothing seems to happen. That is normal on success —
delis silent. Rundirto verify the file is gone. - You deleted the wrong file. Command Prompt deletion is permanent. Check the Recycle Bin anyway (files deleted through Explorer may be there), then look at File History or a backup if one was configured. Otherwise, recovery requires third-party tools and is not guaranteed.
- Wildcard deleted too much. Stop immediately and avoid writing new data to the drive; recovery odds drop as new files overwrite the space.
Frequently Asked Questions
Does del send files to the Recycle Bin?
No. Files deleted from Command Prompt are removed directly and do not appear in the Recycle Bin.
Can I undo a del command?
There is no built-in undo. Recovery depends on backups or third-party recovery software, and success is not guaranteed.
How do I delete a file with spaces in its name?
Wrap the full name or path in double quotes, for example del "my report.txt".
What is the difference between del and erase?
They are effectively the same command; erase is an alias for del and accepts the same options.
Can del remove a folder?
No. Use rmdir or rd for folders, adding /s to include contents.
Why does del *.* ask for confirmation?
Because it matches every file in the folder, Command Prompt prompts as a safety check. Adding /q suppresses the prompt — use it only when you are certain.