' ========================================================================================
' ##### удаленеие файлов по маске
Sub Cleaning_Folder_G_Perso()
pfxbcnrf = FnCleaning_Folder_G_Perso("D:\Public\G_Perso\", "tmp") '"tmp;.xls"
End Sub
'
'-----------------------------------------------------------------------------------------
Function FnCleaning_Folder_G_Perso(ByVal strFolderPath As String, _
ByVal vMask As Variant) As Variant
' strFolderPath - путь(папка)
' vMask - строка с перечислением масок через ";"
Dim blnRun As Boolean
Dim m As Variant
Dim oFile As Variant, strFile As String, strFileName As String
On error resume next
m = Split(vMask, ";", -1, vbTextCompare)
Set FSO = CreateObject("Scripting.FileSystemObject") ' создаём экземпляр FileSystemObject
Set curfold = FSO.GetFolder(strFolderPath)
For Each oFile In curfold.Files ' перебираем все файлы в папке FolderPath
strFile = oFile.Path
strFileName = oFile.Name
For i = LBound(m) To UBound(m)
blnRun = False
strMask = m(i)
If strFileName Like "*" & strMask & "*" Then blnRun = True
Next i
If blnRun Then Kill strFile
strFile = "": strFileName = ""
Next 'oFile
End Function
' ========================================================================================