Windows Del Command, Delete Files Using CMD
del command is used to delete files from the command line in the Windows operating system.
We can delete multiple files at once:
del file1.txt file2.txt
delcommand removes files permanently without sending them to the Recycle Bin.
- If you use the
delcommand prompts for confirmation before deleting each file.
- There is another command, the
erasecommand, and it is identical to the
delcommand, and the syntax is similar.
- To force delete read-only files, use the
- We can use the wildcard (*) character to remove all files in a directory.
- To delete folders, use the rmdir command.
DEL Command Examples
Remove the file
file1.txt in the current directory:
Remove the file
file1.txt in the
The following command uses the
/F option to force delete
file1.txt if it is a read-only file:
del /f file1.txt
Remove all files in the
del /q *
Remove all text files (files with
.txt extension) in the current directory:
Delete all files with the pattern
file.* (e.g., file1.txt, file2.txt, file1.doc, etc.) in the
When using the wildcard character, the
del command prompts for confirmation by default. You can use the
\Q option to suppress the confirmation message.
In the following example, The windows
del command deletes all files from
c:\data and all subdirectories. The
/S option is used to remove the specified file(s) from all subdirectories.
del /s /q C:\data\*
However, the del command does not remove subdirectories, only files inside subdirectories.
The del command does not delete hidden files by default. To include hidden files, use the
del /a:h file1.txt
The following command deletes all hidden files in the current directory:
del /a:h *
/a switch is used to delete files based on their attributes (H represents hidden files). To see a list of all options, type