command syntax for deleting arbitrary files using cmd in Win7 environment

Source: Internet
Author: User
Tags require root directory

first Open the command prompt administrator, open the Run input: CMD

First, delete the file syntax one:

RD Directory Name/s

RD/S Directory Name

Both of these are asked before deletion to delete all content, including the target directory.

Second, delete the file syntax two:

RD Directory Name/s/q

RD/S/q Directory Name

Both are removed without asking for deletion of all content, including the target directory.

Third, remove the attribute and delete the file syntax:

CMD long file name, folder name Shortcut Input Method:

Enter the filename, the first two letters of the folder name, and press Tab to automatically populate the long file name. To delete a folder or file under CMD, first determine if the folder or file has special properties, such as system, read-only, hide.

Remove file attributes (-s system-R read-only-H hide):

Folder:

attrib c:windows-s-r-h

File:

Attrib-s-h-r C:windowsautorun.inf

The delete commands are as follows:

Delete folder (empty):

Rd C:windows

To delete a file:

Del C:windowsautorun.inf

Note: If you are working under the current path, you can omit the path. such as: Rd new folder or del new file. txt

Four, the CMD environment forced delete files:

Delete the file path file name you want to delete, not the path in this folder.

1, deltree--delete the entire Directory command:

①, function: Delete the entire directory and its subordinate subdirectories and files.

②, type: external command

③, Format: deltree[letter:]< path name >

Use instructions: This command can be in one step to delete the directory and all of its files, subdirectories, lower subdirectories together, and regardless of the file's property is hidden, system or read-only, as long as the file is located under the deleted directory, deltree, according to delete. Be careful when using!!!

2. Delete File command del:

①, Format: del[d:][path]filename[/p]

②, type: internal command

③, Function: Deletes one or more specified files and cannot be used to delete subdirectories. The function of the parameter/p is to enable CMD to require the user to approve before deleting each file, allowing the user to selectively delete some files

Example: C:>del TEXT3

This command deletes the TEXT3 file in the current directory of the current disk.

3. Rd Delete subdirectory command

①, Function: Removed directory from specified disk

②, type: internal command

③, Format: rd[letter: [path name] [subdirectory name]

Instructions for use:

①, subdirectories must be empty before deletion, that is, you need to enter the subdirectory, use the DEL (delete file command) to delete the files in their subdirectories, and then back to the previous level of the directory, using Rd command to delete the directory itself;

②, the root directory and the current directory cannot be deleted.

Example: required to delete the test subdirectory under the KAMDY subdirectory of C disk, as follows:

Delete the file in the test subdirectory first;

C:>del C:kamdytest*.*

Delete Test subdirectory

C:>rd C:kamdytest

If you delete the next folder named Kill in D disk rd/s/q d:kill OK.

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

/q Quiet mode.

/s does not require confirmation when deleting a tree.

If you mistakenly delete the file, you can use the undelete command to restore, below, let me introduce this command.

V. Restore DELETE command undelete:

1, Format: Undelete (just deleted the filename)

2. Type: External command

3, Function: Restore mistakenly deleted files

However, to remind you, when inadvertently deleted one or more files, it is best to use the undelete command to recover immediately, otherwise, I am afraid nights, your disk may be saved or copied in other documents, then these inadvertently deleted files will be difficult to recover.

If you delete the first file in your subdirectory wps, you can restore it immediately with C:>undelete c:wps, just enter the first letter of each deleted file.

Under Windows XP, 2000, NT, the rmdir command can be used to delete the entire directory, like saying that I want to delete all directories and files in the directory of test, this syntax is:

rmdir/s/q Test

which

/s is the file that deletes all subdirectories with it.

/q is not to stop asking me for yes or no when deleting files or directories.

You can also specify a path before the directory you want to delete, such as:

rmdir/s/q D:/temp/test

This means telling the computer to delete everything in the test folder in the Temp folder in disk drive D, and don't ask me if I want to delete it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.