Skip to content

Instantly share code, notes, and snippets.

@roachhd
Last active March 12, 2023 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roachhd/22c3d848cb18e4dd6017 to your computer and use it in GitHub Desktop.
Save roachhd/22c3d848cb18e4dd6017 to your computer and use it in GitHub Desktop.
Rmdir - removed long file & folder paths πŸ“ in command prompt

Rmdir (rd)

Removes (that is, deletes) a directory.

Syntax

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

Parameters

[Drive:]Path: Specifies the location and name of the directory that you want to delete.

/s: Removes the specified directory and all subdirectories including any files. Use /s to remove a tree.

/q: Runs rmdir in quiet mode. Deletes directories without confirmation.

/?: Displays help at the command prompt.

Remarks

  • Using rmdir at the Recovery Console

The rmdir command, with different parameters, is available from the Recovery Console.

  • Cannot delete directory with hidden or system files

You cannot delete a directory that contains files, including hidden or system files. If you attempt to do so, the following message appears:

The directory not empty

Use the dir command to list hidden and system files, and the attrib command to remove hidden and system attributes from files.

  • Using the backslash character with the path parameter

If you insert a backslash () before the first directory name in path, the directory is treated as a subdirectory of the root directory, regardless of your current directory. If you do not insert a backslash before the first directory name in path, the directory is treated as a subdirectory of the current directory.

  • Deleting the current directory

You cannot use rmdir to delete the current directory. You must first change to a different directory (not a subdirectory of the current directory) and then use rmdir with a path. If you attempt to delete the current directory, the following message appears:

The process cannot access the file because it is being used by another process.

Examples

To delete a directory named UserSmith, first ensure that the directory is empty. To do this, type:

dir usersmith /a

Only the . and .. symbols should display.

Then, from any directory except UserSmith, type:

rmdir usersmith

To delete the directory User and all of the subdirectories and files, type:

rmdir /s user

Formatting legend

Format Meaning
Italic Information that the user must supply
Bold Elements that the user must type exactly as shown
Ellipsis (...) Parameter that can be repeated several times in a command line
Between brackets ([]) Optional items
Between braces ({}); choices separated by pipe ( ). Example: {even
Courier font Code or program output

Attrib

Mkdir

Dir

Command-line reference A-Z

@roachhd
Copy link
Author

roachhd commented Jan 4, 2015

Originally I tried the del command, but that didn't work. Then I remembered rmdir. Doing the following:

rmdir /S /Q <dir>

seems to have worked.

@MarkShees
Copy link

I tired using the Long Path Tool instead of doing it with codes. It was very easy to do. It worked perfectly for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment