| |
doctortt
Posts: 73
Score: 0
Joined: 6/15/2007
Status: offline
|
Hi guys, I have a script that searches for files with .BAK extention. I would like to add another extenion to the script. How do I do it? Below is my script. I'm a noob in scripting, so I'm trying to keep everything as simple as possible. Option Explicit 'On Error Resume Next Dim objFSO, RegEx, strFolderPath, objFolder, objSubFolder Dim strDate, strDelMax, strMonth, strDay, strYear,retDate, objFile strDate = Now strDelMax = 14 StrMonth = Month(Date) strDay = Day(Date) strYear = Year(Date) strFolderPath = "C:\DBBackup" Set RegEx = New RegExp RegEx.Pattern = "\.(bak)$" RegEx.IgnoreCase = True Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(strFolderPath) Then Set objFolder = objFSO.GetFolder(strFolderPath) For Each objSubFolder In objFolder.SubFolders For Each objFile In objSubFolder.Files RetDate = datediff("d",objFile.datelastmodified,strDate) If RegEx.Test(objFile.Name) and retDate > strDelMax then objFSO.DeleteFile(objFile) End if Next Next End If
|
|