Batch Script Deleting Folders
Deleting Folders
Batch Script provides the del
command to delete folders.
del [/p] [/f] [/s] [/q] [/a[[:]attributes]] names
The options that can be presented to the del
command are described below.
Options | Description |
---|---|
Names | 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 |
/p | Prompts for confirmation before deleting each file. |
/f | Force deletes read-only files. |
/s | Deletes specified files from all subdirectories. |
/q | Quiet mode, do not ask if ok to delete on global wildcard. |
/a | Selects files to delete based on attributes. |
attributes | R Read-only filesS System filesH Hidden filesA Files ready for archiving- Prefix meaning not |
Examples
Let's look at some examples of how the del
command can be used for folders.
The following command will delete the folder called Example in the current working directory.
del Example
The following command will delete the folder called Example in C drive.
del C:\Example
The following command will delete the folder called Example1 and Example2 in the current working directory.
del Example1 , Example2