Scot's Tech Stuff | Scot's Ramblings

Mar/10

26

VBScript to remove subfolders

This will check all IMMEDIATE subfolders of  C:\folderpath\ and if the folder hasn’t been modified in more than 90 days, it will delete it.

This will only work for subfolders on the local system you are running the script from.

Dim fso, f, f1, fc

Set fso = CreateObject(“Scripting.FileSystemObject”)

set f = fso.GetFolder(“C:\folderpath”)

Set fc = f.subFolders

For Each f1 in fc

If DateDiff(“d”, f1.DateLastModified, Now) > 90 Then f1.delete

Next

No tags

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me