I got a code while goggling, the code looks for csv and delete in subfolders .
the actual code delete csv only
note just learning.
Assistance what to modify in the code to delete to delete csv and xlsb only
the actual code delete csv only
note just learning.
Assistance what to modify in the code to delete to delete csv and xlsb only
Code:
Dim FSO As Object
Sub delkillcsv()
Dim myFiles As Object, file As Object
Dim startFold As String
Set FSO = CreateObject("Scripting.FileSystemObject")
startFold = "C:\Test\Demo"
If Right(startFold, 1) = "\" Then
startFold = Left(startFold, Len(startFold) - 1)
End If
Set myFiles = FSO.GetFolder(startFold).Files
For Each file In myFiles
[B] If InStr(file.Name, ".csv") Then[/B]
Kill file.Path
End If
Next
Call chkSubfolder(FSO.GetFolder(startFold))
End Sub
Sub chkSubfolder(fold As Object)
Dim subfolder As Object, fileCol As Object, file As Object
For Each subfolder In fold.Subfolders
Set fileCol = FSO.GetFolder(subfolder.Path).Files
For Each file In fileCol
[B] If InStr(file.Name, ".csv") Then[/B]
Kill file.Path
End If
Next
Call chkSubfolder(subfolder)
Next
End Sub