' Thread: http://www.mrexcel.com/forum/showthread.php?t=601024
' Poster: GDM69
' Written: December 23, 2011
' Author: Leith Ross
Sub DeleteTextFiles(ByVal FolderPath As String)
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 LCase(File.Name) Like "*.txt" Then
File.Delete
End If
Next File
For Each SubFolder In Folder.SubFolders
DeleteTextFiles SubFolder
Next SubFolder
End Sub
Sub Run()
DeleteTextFiles "C:\Gennex"
End Sub