Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Sub Directories 1

Status
Not open for further replies.

Rob23

Technical User
Jan 8, 2004
3
US
Does anyone know of an easy way to grab a <root folder> and delete all sub directories under that folder without deleting the <root folder>?

Thanks,
Rob
 
Try something like this:
Code:
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set rf=fso.GetFolder(&quot;\path\to\root&quot;)
Set sf=rf.SubFolders
For Each f In sf
  f.Delete True
Next

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top