Name
rd or rmdir
Synopsis
Remove (delete) a directory.
Syntax
rd [/s] [/q]path
rmdir [/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\newdir
Delete 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
rd
andrmdir
commands are functionally identical.As a safety feature, attempting to delete a directory that is not empty without including the
/s
option will display the message, “The directory is not empty.”rd
with the/s
option takes the place of thedeltree
command 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 ...
Get Windows XP in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.