Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Deleting a directory structure without deleting the name of the root

09 May 2012   #1

Windows 7
Deleting a directory structure without deleting the name of the root


With the command prompt of Windows 7 SP1, how do I delete a directory structure with their files without deleting the name of the root directory?



My System SpecsSystem Spec
09 May 2012   #2

Windows 8.1 Pro RTM x64

So you want to delete the contents of a folder without deleting the folder itself? Would that also include sub-folders within that folder?

Simply enter cd <path to directory> at the prompt to make the required directory the target of the next command. Then, after verification that this is the correct directory and that you do indeed want to remove its contents, enter del *.* at the prompt. This should delete its contents, but not the directory itself. Please note that content cannot be easily recovered, which is why I asked you to verify the location first.
My System SpecsSystem Spec
09 May 2012   #3

7 x64

Open Win Explorer, highlight the directory in the left hand side, Which will display all sub-folder and files on the right hand side, select all on the right, Press the Delete Key.

Why fool with the CMD Prompt when it is so easily done in Explorer.
My System SpecsSystem Spec


 Deleting a directory structure without deleting the name of the root

Thread Tools

Similar help and support threads
Thread Forum
deleting files in tmp directory
is it safe to manually delete files in C:\Windows\Temp and C:\Users\admin\appdata\Local\Temp thanks in advance
General Discussion
Deleting a 2nd User account & its safety in not deleting anything else
Hoping this is the right place to ask my question and that the title is OK. I was asked to create a 2nd user account with 'Administration privileges'. Having done so I no longer need it. In trying to delete it I got a pop up window asking me if I wanted to save some of my files (My Documents etc.)...
General Discussion
Deleting Former RAID Structure on HDD
I just rebuilt my system using a separate "C" drive for the OS and apps plus a second HDD for data. I'm using Windows 7 Pro. The data drive was previously used as half of a mirrored array. The twin drive is on a shelf in the garage. I reformatted the data drive but am getting a message during POST...
Hardware & Devices
Robocopy /MOV command copying but not deleting from source directory
Hi All, I have one folder A and have another folder B in the same drive E: I need to move all the content from folder A which are more than 2 years old to folder B. Hence when I ran the robocopy it just copied and I lost all disk space in drive E. My question is even though I used /MOV...
General Discussion
Recover Files after deleting partition with folder structure?
Hi, i deleted my partitions by mistake. Drive originally had 2 partitions, 100MB (Windows 7 setup partitiion) and 930GB (Data storage partition). In summary: 1) I deleted the 100MB partition (because disk is(was) now storage disk) and 930gb partition were deleted too. 2) I started following...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 04:07.
Twitter Facebook Google+