What is rd?

RD is a command-line command available on most Microsoft operating systems, primarily used for removing or deleting a directory (folder). It stands for "Remove Directory." It's functionally similar to the rmdir command.

Here's a breakdown:

  • Function: The primary function of RD is to delete empty directories.

  • Syntax: The basic syntax is RD [/S] [/Q] [drive:]path. Let's break this down:

    • RD: The command itself.
    • [/S]: This switch removes a directory tree (a directory including all its subdirectories and files). Using this option prompts for confirmation unless the /Q switch is also specified. You can learn more about the /S%20Switch.
    • [/Q]: This switch enables quiet mode; the RD command does not prompt for confirmation when removing a directory tree with the /S switch. This makes the deletion process automatic. See the details for /Q%20Switch.
    • [drive:]path: Specifies the location of the directory you want to remove. drive: is the drive letter where the directory is located (e.g., C:), and path is the directory's path (e.g., \Users\MyUser\Documents\MyFolder).
  • Usage Notes:

    • By default, RD will only remove empty directories.
    • To remove a directory containing files and/or subdirectories, you must use the /S switch. Use this switch with caution! Deleting a directory tree is irreversible without specialized data recovery tools.
    • RD cannot remove the current directory. You must first change to a different directory before using RD to delete the directory you were previously in.
    • You need appropriate permissions to delete a directory. If you don't have permission, the RD command will fail.
  • Examples:

    • RD C:\EmptyFolder: Removes the empty directory C:\EmptyFolder.
    • RD /S C:\MyFolder: Removes the directory C:\MyFolder and all its contents (subdirectories and files). You will be prompted to confirm the deletion.
    • RD /S /Q C:\MyFolder: Removes the directory C:\MyFolder and all its contents without prompting for confirmation.
  • Alternatives: While RD is designed for removing directories through the command line, the graphical user interface (GUI) also provides ways to delete them. For example, in Windows File Explorer, you can right-click on a directory and select "Delete."