Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Search multiple file extension help.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,66221
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Search multiple file extension help.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Search multiple file extension help. - 11/11/2008 3:44:58 AM   
  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
 
 
Post #: 1
 
 RE: Search multiple file extension help. - 11/11/2008 3:51:44 AM   
  dm_4ever


Posts: 2728
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
\.(bak|jpg|bmp|doc)$

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to doctortt)
 
 
Post #: 2
 
 RE: Search multiple file extension help. - 11/11/2008 4:07:33 AM   
  doctortt

 

Posts: 73
Score: 0
Joined: 6/15/2007
Status: offline
It works. Thanks

(in reply to doctortt)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Search multiple file extension help. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts