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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript to delete folders based on YYMM folder name.

Status
Not open for further replies.

wizzard99

MIS
Oct 14, 2003
4
GB
Hi all,

I've just been given a requirement to automate some folder deletion on a windows box. I'm more of a Unix person so my windows scripting skills are a little weak so I thought i'd ask here.

I'll have a folder that will have a set of subfolders which I need to read the names of, under those folders will be another series of folders named using YYMM for the folder name.

if the high level folder is called recording then this is what I need to do,

List 1st level subfolders of recording, for each of the folders found get the current YYMM values (this will always run on the 1st of the month) and then delete any subfolders that are older than 3 months.

So if the current YYMM value was 1102 I would want to keep 1101, 1012 and 1011 and delete anything else.

Hope someone can help me on this,
Thanks.

 
first start by enum' the root folder?
strRootFolder = "c:\recording"
If FSO.FolderExists(strRootFolder) Then
Set objRootFolder = FSO.GetFolder(strRootFolder)
For Each aSubFolder In objRootFolder.Folders
For Each anotherSubFolder In aSubFolder.Folders
Wscript.Echo anotherSubFolder & " in " & aSubFolder
Wscript.Echo "need to work out the whole date thing"
Wscript.Echo "would suggest the use of a DateDiff"
Wscript.Echo "which means you need to convert anotherSubFolder into a CDate() format, so you can do the DateDiff(m, on Now()"
Next
Next
Set objRootFolder = Nothing
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top