DEL: Deletes one or more files.
The command: "DEL" is on Windows 11, 10, .. available
The examples for the command "DEL"
command in Windows Command Prompt is used to delete files. Here are some examples with comments:
Example 1: Delete a single file:
This command deletes the file "file.txt"
Example 2: Delete multiple files:
DEL file1.txt file2.txt
Here the files "File1.txt"
Example 3: Delete all TXT files in the current directory:
This command deletes all TXT files in the current directory.
Example 4: Delete all files and subdirectories (recursive):
DEL /S /Q directory\
This command deletes all files and subdirectories of the specified directory. `/S`
stands for "recursive"
, and `/Q`
disables the confirmation prompt.
Example 5: Delete all files older than a certain date:
DEL /Q /FOLDER:C:\Path\ /S /D:01-01-2022
Here all files in the "C:\Path\"
directory and in all subdirectories older than January 1, 2022 are deleted. `/Q`
disables the confirmation prompt, and `/S`
stands for "recursive"
Example 6: Delete all files with a specific extension:
This command deletes all LOG files in the current directory.
Example 7: Show help:
This command displays help and information about the available options for the `DEL`
It is important to use the `DEL`
command with caution because deleted files usually cannot be recovered without special software. Make sure you delete the correct files, and note that certain options (like `/S`
) can have far-reaching effects, especially when used together.
"DEL" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
Deletes one or more files.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows:
The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.
Important information, tips for the "DEL" command
There are a few important points to note when using the `DEL`
command in the Windows Command Prompt:
command deletes files irrevocably. There is usually no built-in way to recover deleted files from the Recycle Bin. Make sure you are sure which files you want to delete.
Make sure you have the necessary permissions to delete the selected files. Some system files or protected files require administrator rights.
When using wildcards (, ?) to delete files, be extra careful to avoid accidental deletion. For example, `DEL *.`
could delete all files in the current directory.
command may ask for confirmation if you try to delete multiple files at once. You can disable verification using the `/Q`
DEL /Q file.txt
5. Recursive Deletes:
If you use the `/S`
command for recursive delete, it could delete all files in a directory and its subdirectories. Make sure this is intentional to avoid data loss.
DEL /S /Q directory\
6. Protected System Files:
command may have difficulty deleting protected system files. In some cases, additional permissions or running Command Prompt as administrator are required.
7. Delete files older than a specific date:
When using the `/D`
option in conjunction with the `/S`
parameter to delete files older than a specific date, make sure you use the date format correctly stated.
DEL /S /D:01-01-2022
8. Batch scripts:
When using `DEL`
in a batch script, check the return value (`%ERRORLEVEL%`
) to see if the deletion was successful.
IF %ERRORLEVEL% EQU 0 (
ECHO deletion successful.
) ELSE (
ECHO Error deleting.
9. Show Help:
You can use `DEL /?`
to display help and information about the available options for the `DEL`
Therefore, use the `DEL`
command with caution and make sure you are aware of its implications, especially when working with wildcards, recursive deletion or deleting system files.