Rd command in Windows

The rd command helps delete a directory

The rd command helps delete a directory.This command is similar to the rmdir command.To learn more about how to use this command, see the example section below.

Syntax rd command

 rd [:] [/ s [/ q]] 
rmdir [:] [/ s [/ q]]

Parameter command rd

Parameters

Describe

[:]

Specify the location and name of the folder you want to delete.

/S

Delete a directory tree (the specified directory and all its subdirectories, including all files in the directory).

/ q

Specify silent mode.Do not repeat confirmation when deleting the directory tree.(Note that the / q parameter only works if the / s parameter is specified).

/?

Show help at thecommand prompt.

Note the rd command

You cannot delete folders that contain files, including system files or hidden files.If you still try to do so, the following message will appear:

 Thư mục này không trống 

You can use the dir / a command to list all files (including system files and hidden files) in the directory. Then use the attrib command with the -h parameter to remove hidden file attributes, -s to remove system file attributes, or both -h and -s to remove both hidden and file properties system.

After the properties are hidden and the file has been deleted, you can delete the files with rd command as usual.

If you insert a backslash () at the beginning of the path, the path will be started at the root directory (regardless of the current directory).

You cannot use rd command to delete the current directory.If you still try to delete the current directory, the following error message will appear:

 Tập tin không truy cập được tập tin vì nó được dùng bởi một tiến trình. 

If you receive this error message, you must change to another directory (not the subdirectory of the current directory), and then use the rd command (specify the path if necessary) to proceed with deleting. folder.

The rd command with different parameters will be available in the Recovery Console.

Example rd command

As mentioned, you will not be able to delete the folder you are currently working on.You must change to a folder that is not in the scope of the current directory.For example, to change a message to the root, type:

 cd . 

You can now safely delete the desired folder.

Use the optional parameter / s to delete the directory tree. For example, to remove a folder named Test (including all subfolders and its files) from the current directory, enter:

 rd / s test 

To run the above example in silent mode, enter:

 rd / s / q test 

Attention

When you run rd / s command in silent mode, the entire directory tree will be deleted without confirmation. Therefore, make sure that important files are moved or backed up before you use the / q command line option .

See more:

  1. The qprocess command in Windows
  2. Qappsrv (query termserver) command in Windows
  3. The quser (query user) command in Windows
  4. The pubprn command and the pushprinterconnections command in Windows
3.7 ★ | 26 Vote