Rd command in Windows

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

May be interested

  • Instructions for using Command PromptInstructions for using Command Prompt
    deep in windows is a command-line world that is obscure. in this article, we will show you how to solve errors and make your computer more secure.
  • Cmd command in WindowsCmd command in Windows
    the cmd command starts a new version of the command interpreter, cmd.exe. if used without parameters, cmd will display copyright information and the version of the operating system.
  • How to use the command history function in Command PromptHow to use the command history function in Command Prompt
    command prompt is an extremely familiar command for anyone using windows operating system. besides, a lot of current software also supports the command line to perform actions on the command prompt window, instead of on the screen.
  • The sfc command in WindowsThe sfc command in Windows
    (applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012)
  • Reg command copy in WindowsReg command copy in Windows
    to copy an entry to the location specified on the local pc or the remote computer we will use the reg copy command. to learn more about how to use the reg copy command, you can track the syntax, explain the command parameters and the example tipsmake.com has compiled below.
  • Fc command in WindowsFc command in Windows
    the fc command compares two files or a collection of files and displays the differences between them.
  • The echo command in WindowsThe echo command in Windows
    the echo command displays the message or turns on / off the command repeat feature. if used without parameters, the echo command will display the current echo setting.
  • Xcopy command in WindowsXcopy command in Windows
    the xcopy command is a command prompt command used to copy one or more files or folders from one location to another. with many options and the ability to copy entire directories, the xcopy command is similar to, but much more powerful, than the copy command.
  • The cacls command in WindowsThe cacls command in Windows
    the cacls command displays or modifies an arbitrary access control list (dacl) on the specified file. the command applies to windows server (semi-annual channel), windows server 2016, windows server 2012 r2, windows server 2012.
  • Clean command in WindowsClean command in Windows
    the clean command deletes all partitions or formats the volume from the current drive. the command applies to windows server (semi-annual channel), windows server 2019, windows server 2016, windows server 2012 r2, windows server 2012.