Delete Files/Subfolder but keep parent

Associate
Joined
4 Jun 2007
Posts
2,282
Location
South Wales
Hey guys,

Looking for a way to delete all subfolder and files but keep the parent directory within cmd or if push comes to shove powershell (would prefer cmd so I can make a bat file)

i.e.
C:\Parent\Sub1\*.*
C:\Parent\Sub1\*.*
C:\Parent\Sub2\*.*
C:\Parent\Sub2\Sub3\*.*

Basically I want to keep C:\Parent but delete all of its contents, closest I can find would be RMDIR /S but that would delete C:\Parent as well or using cd C:\Parent which seems like a long winded way to do it, especially if I then want to add C:\Parent2 etc to it
 
Back
Top Bottom