The command: "RMDIR" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "RMDIR"
The
`RMDIR` command in Windows Command Prompt is used to delete directories. Here are some examples of using the
`RMDIR` command:
Example 1: Delete an empty directory:
RMDIR C:\Example\EmptyDirectory
Description: This command deletes the empty directory
"EmptyDirectory" in the path
"C:\Example".
Example 2: Delete a directory with all subfolders and files:
RMDIR /S /QC:\Example\DirectoryWithContents
Description: Using the
`/S` and
`/Q` options recursively deletes the DirectoryWithContents directory including all subfolders and files without prompting for confirmation.
-
`/S`: Deletes all subdirectories and files in the specified directory.
-
`/Q`: Deletes without confirmation.
Example 3: Delete directory and ask for confirmation:
RMDIR /PC:\Example\DirectoryToDelete
Description: The
`/P` option causes the user to be asked for confirmation before deleting the DirectoryToDelete directory.
Example 4: Delete directory and show output:
RMDIR /S /QC:\Example\DirectoryToDelete > DeleteProtocol.txt
Description: The
`/S` and
`/Q` options delete the directory without confirmation and the output is redirected to a file named
"DeleteProtocol.txt". The log contains information about the deletion process.
It is important to be careful when using
`RMDIR`, especially with the
`/S` and
`/Q` options, as this may result in irreversible loss of data. Make sure you specify the correct directory and that you have backed up all important data before deleting a directory.
"RMDIR" 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 "RMDIR" command
Yes, there are some important points you should pay attention to when using the
`RMDIR` command in the Windows Command Prompt:
1.
Prevent data loss: The
`RMDIR` command permanently deletes directories and all files and subdirectories they contain. Make sure you delete the correct directory and that no important data is lost.
2.
Confirmation Prompt: You should be particularly careful when using the
`/S` switch (delete recursively) or the
`/Q` switch (quietly without confirmation prompt). There is no query and the action is taken immediately. Make sure you understand the intended behavior.
3.
Backup: Before deleting directories, especially if they are important directories or if you use the command recursively (
`/S`), make a backup of your data. This helps avoid possible data loss.
4.
Recursive deletion: The
`/S` switch causes the directory to be deleted recursively with all subdirectories and files. Be aware that this will remove all contents of the directory.
5.
Confirmation Prompt with `/P`: You can use the
`/P` option to ask for confirmation before deleting a directory. This gives you an extra level of security to avoid accidental deletions.
Example:
RMDIR /S /QC:\Example\DirectoryToDelete
Here the directory Directory to be deleted in the path C:\Example is deleted recursively and without confirmation. Be sure you intend to do this to avoid data loss.
In summary, it is advisable to use
`RMDIR` with caution and ensure that you understand the implications of the command options to avoid unwanted data loss.