For deleting files, Batch Script provides the DEL command.
DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
Following are the description of the options which can be presented to the DEL command.
|S.No.||Options & Description|
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
Prompts for confirmation before deleting each file.
Force deletes of read-only files.
Deletes specified files from all subdirectories.
Quiet mode, do not ask if ok to delete on global wildcard.
Selects files to delete based on attributes.
R Read-only files, S System files, H Hidden files, A Files ready for archiving - Prefix meaning not
Following examples show how the DEL command can be used.
The above command will delete the file test.bat in the current directory, if the file exists.
The above command will delete the file C:\test.bat in the current directory, if the file exists.
The * (asterisks) is a wild character. *.bat indicates that you would like to delete all bat files in the c:\directory.
The ? (question mark) is a single wild character for one letter. The use of this command in the above example will delete any file ending with "est.tmp", such as pest.tmp or test.tmp.