The command: "RD" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "RD"
The
`RD` command in Windows Command Prompt is used to remove (delete) a directory. Here are some examples of using the
`RD` command:
Example 1: Delete directory:
RD C:\Example
Description: This command deletes the C:\Example directory. Note that the directory must be empty for it to be deleted successfully.
Example 2: Delete directory with /S and /Q:
RD /S /QC:\Example
Description: Here the directory
"C:\Example" and all its subfolders and files are deleted recursively and without queries. Caution: This command deletes everything in the specified directory.
Example 3: Delete directory with wildcards:
RD /S /Q "C:\Directory\*.*"
Description: Wildcards allow all files in the directory to be deleted before the directory itself is deleted.
Example 4: Delete directory with relative paths:
RD /S /Q ..\Example
Description: Here a directory is deleted using a relative path (here
"..\Example").
Example 5: Delete directory and ignore errors:
RD C:\NonExistingDirectory 2>NUL
Description: This is attempting to delete the directory
"C:\NonExistingDirectory". If it does not exist, the error is ignored and no message is issued.
Note: Using
`RD` is powerful and should be done with caution, especially when using the
`/S` (recursive) and
`/Q` (no-question) options. The deletion operation is irreversible and data may be irretrievably lost. Make sure you understand the implications before using this command.
"RD" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
C:\\WINDOWS>
Removes (deletes) a directory.
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.
/Q Quiet mode, do not ask if ok to remove a directory tree with /S
Important information, tips for the "RD" command
There are a few important points to note when using the
`RD` (Remove Directory) command in the Windows Command Prompt:
1.
Directory emptiness: The directory to be deleted must be empty. Otherwise, an error message will be displayed unless the
`/S` (recursive) option is used together with
`/Q` (without prompt).
2.
Recursive Deletion: The
`/S` option causes the command to work recursively, that is, it deletes the specified directory and all its subfolders and files. Please note that this may result in data loss if not used carefully.
3.
Missing Directories: If the directory to be deleted does not exist, an error message will be displayed. You can work around this with
`2>NUL` to suppress error messages.
4.
Permissions: Make sure you have the necessary permissions to delete the directory. You need write access to the parent directory.
5.
Option `/Q` (Quiet Mode): The
`/Q` option causes no confirmation to be requested for deleting files and directories. This can be dangerous as files and directories are deleted without prompting.
Here are some examples of using
`RD`:
Example 1: Default deletion:
RD C:\Example
Example 2: Recursive deletion without query:
RD /S /QC:\Example
Example 3: Recursive deletion with relative paths:
RD /S /Q ..\Example
Example 4: Ignore error if directory does not exist:
RD C:\NonExistingDirectory 2>NUL
Note: Be extremely careful when using
`RD`, especially when using the recursive options
`/S` and
`/Q`. Always double check that you are specifying the correct directory to avoid unwanted data loss.