I have code to delete files in subfolders, but not the folders themselves. I have two problems... first the code does not work correctly. It deletes files in the first subfolder, but not folders further up and not in the initial folder.
Second, I would like to delete only files that have not been modified in the last 2 months. In other words, files older than 2 months. If there is better code, then please disregard my code. Here is the code I have (which does not work)... thanks for the help!
on error resume next
Set oFS = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\_test"
For Each subfolder in oFS.GetFolder(sFolder).Subfolders
For Each file in oFS.GetFolder(subfolder.Path).Files
oFS.DeleteFile file.Path, True
For Each folder in oFS.GetFolder(subfolder.Path).Subfolders
Set oFS = Nothing