mistux Site Admin
Joined: 25 Jun 2004 Posts: 1042 Location: South Bend, Indiana USA
|
Posted: Fri May 02, 2008 11:12 am Post subject: Deleting Files in a Directory with Names That Match a Regula |
|
|
' Deleting Files in a Directory with Names That Match a Regular Expression
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 |
|