Name
rd or rmdir
Synopsis
Remove (delete) a directory.
Syntax
rd [/s] [/q]pathrmdir [/s] [/q]path
Description
Unlike in Windows Explorer, files and folders are deleted
differently; if you try to use del to delete a
directory, it will simple delete all the files in the directory, but
the directory itself will remain. rd is used to
delete empty directories and, optionally, to delete directories and
all of their contents.
rd accepts the following options:
-
path Specifies the directory to delete.
-
/s Removes all files and subdirectories of the specified directory.
-
/q Quiet mode; don’t prompt when using
/s.
Examples
Delete the empty subdirectory called newdir
located in the c:\olddir directory:
C:\>rd c:\olddir\newdirDelete the directory Online Services and all of
its contents within the current directory, c:\Program
Files:
C:\Program Files>rd /s "online services"Note that quotes must be used with rd for folders
with spaces in their names.
Notes
The
rdandrmdircommands are functionally identical.As a safety feature, attempting to delete a directory that is not empty without including the
/soption will display the message, “The directory is not empty.”rdwith the/soption takes the place of thedeltreecommand found in earlier versions of Windows, but no longer included in Windows XP.If you try to delete the current directory, you’ll get the following error: “The process cannot access the file because it is being used by another process.” In this case, you’ll have to change to a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access