Unlike deleting files normally, data removed with the del command doesn’t end up in Recycle Bin.
Del Command Availability
The del command is available from within the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems. It can also be used in Command Prompt in the Advanced Startup Options and System Recovery Options repair/recovery menus. In Recovery Console in Windows XP and Windows 2000, the delete Recovery Console command can be used instead.
Del Command Syntax
del [/p] [/f] [/s] [/q] [/a[:]] filename [/?]
Delete File in Specific Folder
In the above example, the del command is used to remove twain_32.dll located in the C:\Windows folder.
Delete File From Current Folder
Here, the command has no path information specified, so the io.sys file is deleted from whatever directory you typed the command from. For example, if you type del io.sys from the C:> prompt, the io.sys file will be deleted from C:.
Delete All EXE Files
This one removes all EXE files from the Tim user’s Downloads folder. The file extension could be replaced with * to delete every file from that folder.
Delete Every Archived File
Use this del command to delete every archived file in the current working directory. Similar to the io.sys command above, this one would execute on whatever folder Command Prompt is set to.
Delete By Attribute and Extension
To combine a few of the del switches, consider this command which will delete every read-only (/a:r) DOCX file from the user’s Documents folder, but will do so in quiet mode (/q) so that you’re not asked to confirm it.
Delete Files From Subfolders
This command will delete every file (.) from every folder (/s) inside the Adobe folder in the user’s Documents directory. The folders will remain, but every file will get removed. However, in this example, you’ll be prompted to enter Y for each file to confirm that you do, in fact, want to delete each one. To avoid that, if you’re sure you want to delete every single file, you can add the /q switch before or after the /s switch to run the command in quiet mode. Just like with the DOCX example above, the wildcard (.) in this command can be changed to anything to remove only those files. Use *.MP4 for MP4s, *.MP3 for MP3s, etc.
Del Related Commands
The erase command is identical to the del command, so either can be used with the same result. In other words, you can replace “del” with “erase” in any of the command examples above without interrupting the instructions. The command forfiles is sometimes used with the del command to remove files that are so-many days old. For example, you might want to delete files that are older than a month in a specific folder, something you can do with forfiles and del but not with just the del command itself. In Windows XP and newer versions of Windows, rmdir is used to erase a whole folder, while deltree is used for the same purpose in operating systems older than Windows XP. In MS-DOS, the undelete command is used to restore files that were deleted with the delete command. To undo the del command in newer versions of Windows, try a file recovery program.