Option Explicit
Option Compare Text
Sub DeleteBackupFiles(ByVal FolderPath As String)
' Author: Leith Ross
Dim File As Object
Dim Folder As Object
Dim FSO As Object
Dim SubFolder As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(FolderPath)
For Each File In Folder.Files
If File.Name Like "[COLOR=#ff0000]*backup*[/COLOR].*" Then
File.Delete
End If
Next File
For Each SubFolder In Folder.SubFolders
DeleteBackupFiles SubFolder
Next SubFolder
End Sub
Sub Run()
DeleteBackupFiles "C:\test"
End Sub