Hi
With the Command Prompt in Windows 8.x, which command should I use to delete all files and all subdirectories of a directory without deleting this root directory?
Thanks
Bye
Technology Tips and News
Hi
With the Command Prompt in Windows 8.x, which command should I use to delete all files and all subdirectories of a directory without deleting this root directory?
Thanks
Bye
I have tried in this way:
del /f /s /q "<directory_path>\*"
but it does not work because
all files are deleted
but its nested subdirectories
are not deleted. Why?
Thanks
Bye
Hi
With the Command Prompt in Windows 8.x, which command should I use to delete all files and all subdirectories of a directory without deleting this root directory?
Thanks
Bye
which command should I use to delete all files and all subdirectories of a directory without deleting this root directory?
rd /s /? while you are in it.
which command should I use to delete all files and all subdirectories of a directory without deleting this root directory?
rd /s /? while you are in it.
Hi balubeto,
I am afraid there is not such a parameter to achieve your goal directly.
With the rd command line and the parameter "/s, /q", we can easily delete all the contents include the root directory .
As a work around ,we can make a bat file and use mkdir to recreate the root directory.
rd /s /q folder path
mkdir folder path
Here are links for reference of using the Del and Rd command line
Del
https://technet.microsoft.com/en-us/library/cc771049.aspx?f=255&MSPPError=-2147217396#BKMK_examples
Rmdir (rd)
https://technet.microsoft.com/en-us/library/bb490990.aspx
Best regards
Only if you are not in the root directory at the time. If you have it open in the Command Prompt, there is a warning about that, which achieves the objective, even though a normal application of the command would delete the specified root too.With the rd command line and the parameter "/s, /q", we can easily delete all the contents include the root directory .