$sDeleted_FilesList = _RAWFilesDelete_Proc("C:\Photos", "PEF|DNG", "JPG", 1) $iDeleted = @extended If $iDeleted > 0 Then MsgBox(64, "Результат", StringFormat("Список файлов которые были удалены [%i]:\n\n%s", $iDeleted, $sDeleted_FilesList)) Else MsgBox(64, "Результат", "Ни один файл небыл удалён.") EndIf Func _RAWFilesDelete_Proc($sPath, $sFilter="PEF|DNG", $sCompare_Ext="JPG", $iRecursive=1) If Not StringInStr(FileGetAttrib($sPath & "\"), "D") Then Return SetError(1, 0, 0) Local $hSearch, $sFindNext, $sFilePath, $i = 0, $iDeleted = 0, $sDeleted_FilesList = "" Local $iMax_Ret_Paths = 10000 Local $aPathesArr[$iMax_Ret_Paths+1] = [1, $sPath] While $i < $aPathesArr[0] $i += 1 $hSearch = FileFindFirstFile($aPathesArr[$i] & "\*") If $hSearch = -1 Then ContinueLoop While 1 $sFindNext = FileFindNextFile($hSearch) If @error Then ExitLoop $sFilePath = $aPathesArr[$i] & "\" & $sFindNext If StringInStr(FileGetAttrib($sFilePath & "\"), "D") Then If $aPathesArr[0] >= $iMax_Ret_Paths Then $iMax_Ret_Paths *= 2 ReDim $aPathesArr[$iMax_Ret_Paths+1] EndIf $aPathesArr[0] += 1 $aPathesArr[$aPathesArr[0]] = $sFilePath Else If Not StringRegExp($sFilePath, "(?i)\.(" & $sFilter & ")$") Then ContinueLoop If FileExists(StringRegExpReplace($sFilePath, "\.[^\.]*$", "." & $sCompare_Ext)) Then ContinueLoop If FileDelete($sFilePath) Then $iDeleted += 1 $sDeleted_FilesList &= $sFilePath & @CRLF EndIf EndIf WEnd FileClose($hSearch) If Not $iRecursive Then ExitLoop Wend Return SetExtended($iDeleted, $sDeleted_FilesList) EndFunc |