Tuesday 11 October 2011

Delete the files thru Command Prompt

Questions received:
        Deleting the file thru GUI takes much downtime.

Solution:
       Deleting the files thru the command prompt makes it passive and quiet.


'DEL' Command
       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

Examples:

To delete HelloWorld.TXT
DEL HelloWorld.TXT

To delete "Hello Big World.TXT"
DEL "Hello Big World.TXT"

To delete all files that start with the letter A
DEL A*

To delete all files that end with the letter A
DEL *A.*

To delete all files with a .DOC extension
DEL *.DOC

To delete all read only files
DEL /a:R *

To delete all files including any that are read only
DEL /F *

[Note:] Run these commands as Administrator, if needed.

No comments:

Post a Comment