Friday, April 27, 2012

DEL / ERASE - Dos Command :

It is used to delete one or more files.
You can use Del command or Erase command to perform deletion operation.
To view 'erase or del' command with its all possible parameters you can use following command. Its like help information to regarding that command.
erase/?

OR

del/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)
Syntax :

 DEL [/P] [/F] [/S] [/Q] [/A[[:] attributes]] names 
 or  ERASE [/P] [/F] [/S] [/Q] [/A[[:] attributes]] names

where,

names: It specifies a list of one or more files or directories. If a special kind of directory is mentioned then all files within it will be deleted. Here, wildcards can be used to delete multiple files.

/P : It prompts for confirmation before deleting each and every file.

/F : It forces deleting of read-only files.

/S : It deletes specified files from all subdirectories.

/Q : This is a Quiet mode. It do not ask if ok to delete on global wildcard.

/A : It is used to select files to delete based on attributes.

attributes are:
S - System Files
H - Hidden Files
R - Read-Only Files
A - Files ready for archiving

If command semantics are enabled then DEL and ERASE changes as follow:

The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find.

Use 1:

del /p C:\test1
- It deletes files located inside test1 directory only.

Output 1:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /p C:\test1
C:\test1\green.txt, Delete (Y/N)? y

D:\DINESH > _

Use 2:

del /f C:\test1
- It forcefully deletes files located inside test1 directory only.

Output 2:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /f C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 3:

del /s C:\test1
- It deletes files located inside test1 directory and also the other files which are located in sub-directories.

Output 3:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /s C:\test1
C:\test1\*, Are you sure (Y/N)? y
Deleted file - C:\test1\green.txt
C:\test1\test2*, Are you sure (Y/N)? y
Deleted file - C:\test1\test2\green.txt

D:\DINESH > _

Use 4:

del /q C:\test1
- It deletes files located inside test1 directory only without describing any operations.

Output 4:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /q C:\test1

D:\DINESH > _

Use 5:

del /a:r C:\test1
- It deletes files which are having read only attributes from test1 directory only.

Output 5:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > del /a:r C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 6:

erase /p C:\test1
- It erases files located inside test1 directory only.

Output 6:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /p C:\test1
C:\test1\green.txt, Delete (Y/N)? y

D:\DINESH > _

Use 7:

erase /f C:\test1
- It forcefully erases files located inside test1 directory only.

Output 7:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /f C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

Use 8:

erase /s C:\test1
- It erases files located inside test1 directory and also the other files which are located in sub-directories.

Output 8:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /s C:\test1
C:\test1\*, Are you sure (Y/N)? y
Deleted file - C:\test1\green.txt
C:\test1\test2*, Are you sure (Y/N)? y
Deleted file - C:\test1\test2\green.txt

D:\DINESH > _

Use 9:

erase /q C:\test1
- It erases files located inside test1 directory only without describing any operations.

Output 9:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /q C:\test1

D:\DINESH > _

Use 10:

erase /a:r C:\test1
- It erases files which are having read only attributes from test1 directory only.

Output 10:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > erase /a:r C:\test1
C:\test1\*, Are you sure (Y/N)? y

D:\DINESH > _

No comments:

Post a Comment