In the Win7 environment, the command syntax for deleting arbitrary files using CMD is

  

In Win7 system, many files cannot be deleted. Such files can be deleted by CMD commands. For example, if the user does not want to use the right button to delete and want to delete multiple directories at one time, the CMD command can still be implemented. However, before deleting the file, a delete prompt box will pop up. We can still use the CMD command to delete the prompt without displaying the prompt. Can the file that was ordered to be deleted be restored? For details, please refer to the following to understand the command syntax for deleting arbitrary files using CMD in Win7 environment.


& uarr; example, do not really try!

First open the command prompt administrator, open the run input: CMD

First, delete the file syntax:

rd directory name /s

rd /s Directory Name

These two are asked to delete everything including the target directory before deleting.

Second, delete the file syntax 2:

rd directory name /s /q

rd /s /q directory name

These two are deleted Do not ask to delete all content including the target directory before.

Third, remove the attribute and delete the file syntax:

CMD long file name, folder name shortcut input method:

Input file name, folder name first two The letters, press Tab, will automatically fill in the long file name. To delete a folder or file under CMD, first determine if the folder or file has special attributes, such as “system”,“read-only';“hidden”.

Remove file attributes (-s system -r read-only -h hidden):

Folder:
attrib c:\\windows -s -r -h

File:
attrib -s -h -rc:\\windows\\autorun.inf

The delete command is as follows:

Delete folder (empty):
rd c:\\windows

Delete file :
del c:\\windows\\autorun.inf

Note: If you are operating in the current path, you can omit the path. Such as: rd New folder or del new file.txt

Fourth, forced deletion of files in CMD environment:

delete File path file name you want to delete, no path in this folder .

1, DELTREE —— delete the entire directory command:

1, function: delete the entire directory and its subdirectories and files.

2, type: external command

3, format: DELTREE [drive letter:] < path name >

Instructions for use: This command can be used in one step All files, subdirectories, and subdirectories under it are deleted together, and regardless of whether the attributes of the file are hidden, system, or read-only, as long as the file is located in the deleted directory, DELTREE is treated equally and is deleted. . Be careful when using it! ! !

2, delete the file command DEL:

1, format: DEL[d:][path]filename[/P]

2, type: internal command

3. Function: Delete one or more files specified, which cannot be used to delete subdirectories. The function of the parameter /P is to enable the CMD to require the user to approve before deleting each file, so that the user can selectively delete some files

Example: C:\\>DEL TEXT3

This command will delete the TEXT3 file in the current directory of the current disk.

3, rd delete subdirectory command

1, function: delete the directory from the specified disk

2, type: internal command

3, Format: rd[drive letter:][path name][subdirectory name]

Instructions for use:

1. Subdirectories must be empty before deletion, that is, you need to enter In this subdirectory, use del (the command to delete the file) to delete the files in its subdirectory, and then return to the upper directory, delete the directory itself with the rd command;

2, can not delete Root directory and current directory.

Example: Require the deletion of the test subdirectory under the kamdy subdirectory of the C drive. The operation is as follows:

First delete the files in the test subdirectory;
c:\\> Del c:\\kamdy\\test\\*.*

Delete the test subdirectory\\
c:\\>rd c:\\kamdy\\test

If you delete the folder named kill in the D drive /s /qd:\\kill is ok.

/s In addition to the directory itself, all subdirectories and files in the specified directory are also deleted for the directory tree.

/q Quiet mode.

/s No confirmation is required when deleting the directory tree.

If you delete the file by mistake, you can use the UNDELETE command to restore it. Below, let me introduce this command.

V. Restore Delete Command UNDELETE:

1. Format: UNDELETE (file name just deleted)

2. Type: External Command

3, function: restore accidentally deleted files

However, to remind you, when you accidentally delete one or more files, it is best to use the UNDELETE command to restore immediately, otherwise, I am afraid that night long dreams, your It is possible to save or copy other files on the disk, and these files that have been accidentally deleted are difficult to recover.

If your subdirectory wps deletes the first file, you can immediately restore it with C:\\>UNDELETE C:\\wps, just enter the first letter of each deleted file. It is.

Under Windows XP, 2000, NT, you can use the rmdir command to delete the entire directory. For example, I want to delete all directories and files under the test directory. The syntax is:
rmdir /s/q test

Where:

/s is to delete all subdirectories and files in them.

/q is not to ask me to stop Yes or No when deleting files or directories.

You can also specify the path before deleting the directory, for example:
rmdir /s/qd:/temp/test

This means telling the computer to put the temp folder in the disk drive D Everything in the test folder is deleted, and don't ask me if I want to delete it.

The above is about the command syntax of using CMD to delete arbitrary files in Win7 environment. As long as you use these grammars, you can delete files that cannot be deleted as you like, and the scope of use can even cover the entire hard disk.

Copyright © Windows knowledge All Rights Reserved