Batch Script - Deleting Folders


Advertisements

For deleting folders, Batch Script provides the DEL command.

Syntax

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
1.

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

2.

/P

Prompts for confirmation before deleting each file.

3.

/F

Force deletes read-only files.

4.

/S

Deletes specified files from all subdirectories.

5.

/Q

Quiet mode, do not ask if ok to delete on global wildcard.

6.

/A

Selects files to delete based on attributes.

7.

attributes

R - Read-only files, S - System files, H - Hidden files, A - Files ready for archiving - Prefix meaning not

Let’s look at some examples of how the DEL command can be used for folders.

Examples

del Example

The above command will delete the folder called Example in the current working directory.

del C:\Example

The above command will delete the folder called Example in C drive.

Del Example1 , Example2

The above command will delete the folder called Example1 and Example2 in the current working directory.

batch_script_functions.htm
Advertisements