In this guide, We’ll learn about Del command. This is a particular command used to delete files, folders, and data from a Windows directory. We can run Del command with a simple syntax and set multiple attributes to perform the task. There are two syntaxes “del’ and “erase” that we can use along with parameters.
del [/p] [/f] [/s] [/q] [/a[:]][<Attributes>] <Names> erase [/p] [/f] [/s] [/q] [/a[:]][<Attributes>] <Names>
We can set specific parameters for a specific condition, Here are the following parameters with description.
|/p||Prompt confirmation box before deleting|
|/f||Force to delete|
|/s||Delete all the files from the current directory and its subdirectories|
|/q||Ignore the deletion confirmation|
|/a[:]||r Read-only files|
h Hidden files
i Not content indexed files
l Reparse points
s System files
a Files ready for archiving
|<Names>||Files or folder name, you want to delete|
Del Command Usages
- If you use del /p <name>, It prompts the following message and takes your confirmation.
Filename, Delete (Y/N)?
Simply, type Y for yes and N for No, You can abort this using Ctrl+C key if you don’t want to delete.
- del /f <name>, It will force to delete the selected file, This is only for read-only files.
- del /s, It will delete all the files from the directory and subdirectories, and display file name with a confirmation prompt.
- Similarly, you can use /q and /a[:] Attributes, /q is for without confirmation deletion, and /a:r is for the read-only files.
Type del /a:r, This will delete all the read-only files form the current folder.
# In order to delete all the files from the current folder, you can use the following command. For example, you have a folder named test-folder, then you can type the following command.
Command: del test-folder
This command does delete all the files form the test-folder. You can use Wildcard (*) to delete all the files at once, but when you run the above command it automatically appends this \* at the end.
Command: del test-folder\*
# To delete the specific files you can specify the extension name, For example, you want to delete all the files with the .bat extension, then you can run the following command.
Command: del *.bat
This command will delete all the files having bat extension.
This is all about Del command on Windows NT family. Hopefully, you enjoyed this useful guide, Now you’re ready to delete files using command prompt.