Delete one or more files.
Syntax DEL [options] [/A:file_attributes] files_to_delete Key files_to_delete : This may be a filename, a list of files or a Wildcard options /P Give a Yes/No Prompt before deleting. /F Ignore read-only setting and delete anyway (FORCE) /S Delete from all Subfolders (DELTREE) /Q Quiet mode, do not give a Yes/No Prompt before deleting. /A Select files to delete based on file_attributes file_attributes: R Read-only -R NOT Read-only S System -S NOT System H Hidden -H NOT Hidden A Archive -A NOT Archive Wildcards: These can be combined with part of a filename * Match any characters ? Match any ONE character
If a folder name is given instead of a file, all files in the folder will be deleted, but the folder itself will not be removed.
Delete "Hello World.txt"
DEL "Hello World.txt"
Delete all files that start with the letter A
Delete all files that end with the letter A
Delete all files with a .doc extension:
Delete all read only files:
DEL /a:R *
Delete all files including any that are read only:
DEL /F *
Deleting a file will not prevent third party utilities from un-deleting it again. Secure file deletion utilities are available, however for casual use, you can turn any file into a zero-byte file to destroy the file allocation chain like this:
TYPE nul > C:\examples\MyFile.txt
Files are sometimes created with the very long filenames or reserved names: CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL
To delete these use the syntax: DEL \\.\C:\somedir\LPT1
Alternatively SUBST a drive letter to the folder containing the file.
If a file (or folder) still appears to be 'undeletable' this is often caused by the indexing service. Stopping the service will often enable the file to be deleted.
Delete Locked files (Typically IE temp files or the Offline cache)
Close all applications
Open a command prompt
Click Start, and then Shut Down
Simultaneously press CTRL+SHIFT+ALT.
While you keep these keys pressed, click Cancel in the Shut Down Windows dialog box.
In the command prompt window, navigate to the cache location, and delete all files from the folder (DEL /s)
At the command prompt, type explorer, and then press ENTER.
Older versions of Windows had the DELTREE command that deletes all files and sub folders. The script below, DelTree.cmd can replicate this functionality:
:: Remove all files and subfolders but NOT the root folder :: From tip 617 at JsiFAQ.com @echo off if "%1"=="" goto:eof pushd %1 del /q *.* for /f "Tokens=*" %%G in ('dir /B') do rd /s /q "%%G" popd
Normally DEL will display a list of the files deleted, if Command Extensions are disabled; it will instead display a list of any files it cannot find.
DEL is an internal command. ERASE is a synonym for DEL
“It devoured my paper, it was a really good paper” - Ellen Feiss
DELPROF Delete NT user profiles
Delrp - Delete a file/directory and NTFS reparse points.(Win 2K ResKit)
RD - Delete folders or entire folder trees ()
CleanMgr - Automated cleanup of Temp files, Internet files, downloaded files, recycle bin
FORFILES - Delete files older than X days
INUSE - updated file replacement utility (may not preserve file permissions)
Q315226 - Remove Files with Reserved Names
Q320081 - You cannot delete a file or folder
Q159199 - A file cannot be deleted (NTFS)
PowerShell: Remove-Item - Delete the specified items.
Equivalent bash command (Linux): rmdir / rm - Remove folders/ files