Skip to main content

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.

OptionsDescription
NamesSpecifies 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
/pPrompts for confirmation before deleting each file.
/fForce deletes read-only files.
/sDeletes specified files from all subdirectories.
/qQuiet mode, do not ask if ok to delete on global wildcard.
/aSelects files to delete based on attributes.
attributesR Read-only files
S System files
H Hidden files
A 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

Table of Contents