Please be patient with me on this, I am very new to coding.
I have seen a few examples of code to delete folders older than a certain date, but I would like to delete subfolders of subfolders. for example
c:\test\Archive\B7607\20121001_042315 Under the Archive there are many of the folders that have BXXXX and under each of those folders there are very many date_time folders.
I only need to delete the date_time folders that are odler than 30 days.
I have used the following
It not only deletes the date_time folders, but also the containing folder. Any help would greatly be appreciated.
I have seen a few examples of code to delete folders older than a certain date, but I would like to delete subfolders of subfolders. for example
c:\test\Archive\B7607\20121001_042315 Under the Archive there are many of the folders that have BXXXX and under each of those folders there are very many date_time folders.
I only need to delete the date_time folders that are odler than 30 days.
I have used the following
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
ff = "C:\Test\Archive" ' your A folder
Set fo = fs.GetFolder(ff)
For Each sfo In fo.subfolders
If DateDiff("d", sfo.datecreated, Date) > 30 Then sfo.Delete
Next
set fs = nothing