Demonstration script that deletes files in a given directory that match a regular expression.

Visual Basic
Edit|Remove
strFolderName = "C:\scripts\textfiles\delete\"
strREPattern = "log\d\d_\d\d05\.txt"

Set objFS = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFS.GetFolder(strFolderName)
Set objRE = new RegExp
objRE.Pattern    = strREPattern
objRE.IgnoreCase = True

For Each objFile In objFolder.Files
   If objRE.Test(objFile.Name) Then
      objFS.DeleteFile(strFolderName & objFile.Name)
   End If
Next