Experts Exchange connects you with the people and services you need so you can get back to work.
Be seen. Boost your question’s priority for more expert views and faster solutions
Const conBaseDir = "C:\EE\Temp"
Const conDelAge = 7
' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
' Call recursive routine to clean out old folders
CleanFolder objFSO.GetFolder(conBaseDir), conDelAge
' Release file system object
Set objFSO = Nothing
' Recursive subroutine to remove old subfolders
Sub CleanFolder(objFolder, intAge)
' See if this folders subfolders are old enough to delete.
For Each objSubFolder In objFolder.SubFolders
If DateDiff("d", objSubFolder.DateCreated, Now) >= intAge Then
Wscript.Echo "Deleted Folder: [" & objSubFolder.Path & "], Age: [" & DateDiff("d", objSubFolder.DateCreated, Now) & "]"
CleanFolder objSubFolder, intAge
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $122.40.
Premium members get this course for $159.20.
Premium members get this course for $62.50.
Premium members get this course for $151.20.
Premium members get this course for $389.00.
Premium members get this course for $79.20.