Maza Faka

Advanced Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору jupiter1976 Цитата: Вот набросал на скорую руку, вроде работает: Код: #include <GuiConstants.au3> #include <GuiListView.au3> #include <Date.au3> Global $Age $hGUI = GUICreate("Old files remover", 400, 300) $hListView = _GUICtrlListView_Create($hGUI, "File|Date", 10, 10, 380, 170, BitOR($LVS_REPORT, $LVS_SINGLESEL), $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, _ $LVS_EX_INFOTIP)) _GUICtrlListView_SetColumnWidth($hListView, 0, 260) _GUICtrlListView_SetColumnWidth($hListView, 1, 116) GUICtrlCreateLabel("File Type:", 10, 200, 50, 16) $TypeInput = GUICtrlCreateInput("tmp;temp;bak", 97, 198, 150, 20) GUICtrlCreateLabel("Age in day:", 280, 200, 55, 16) $AgeInput = GUICtrlCreateInput("", 335, 198, 55, 20, $ES_NUMBER) GUICtrlCreateLabel("Directory to Scan:", 10, 230, 90, 16) $DirInput = GUICtrlCreateInput(@MyDocumentsDir, 97, 228, 265, 20, BitOR($ES_READONLY, $ES_AUTOHSCROLL)) $DirButton = GUICtrlCreateButton("", 365, 228, 25, 20, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", 4, 0) $ScanButton = GUICtrlCreateButton("Scan", 10, 265, 80, 23) $CloseButton = GUICtrlCreateButton("Close", 315, 265, 80, 23) $DelButton = GUICtrlCreateButton("Delete selected", 160, 265, 90, 23) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $CloseButton ExitLoop Case $DirButton _SelectFolder() Case $ScanButton _Prepare() Case $DelButton _DeleteFiles() EndSwitch WEnd Func _SelectFolder() GUISetState(@SW_DISABLE, $hGUI) Local $iSelectFolder = FileSelectFolder("Select a folder for scan", "", 0, @MyDocumentsDir) GUISetState(@SW_ENABLE, $hGUI) If $iSelectFolder = "" Then Return False GUICtrlSetData($DirInput, $iSelectFolder) EndFunc Func _Prepare() Local $aType = GUICtrlRead($TypeInput) If $aType = "" Then _MsgBox(48, "File Type", "Please enter a valide file type", $hGUI) GUICtrlSetState($TypeInput, $GUI_FOCUS) Return False EndIf Local $iAge = GUICtrlRead($AgeInput) If $iAge = "" Then _MsgBox(48, "File Type", "Please enter a valide age", $hGUI) GUICtrlSetState($AgeInput, $GUI_FOCUS) Return False EndIf $Age = ($iAge * 24 *60 *60) ConsoleWrite($Age & @LF) $aType = StringSplit($aType, "; |,") _GUICtrlListView_DeleteAllItems($hListView) _GetOldFiles(GUICtrlRead($DirInput), $aType) Local $iCount = _GUICtrlListView_GetItemCount($hListView) If $iCount < 1 Then _MsgBox(48, "Result", "Required files not found", $hGUI) Else _MsgBox(64, "Result", "Found a " & $iCount & " files", $hGUI) EndIf EndFunc Func _GetOldFiles($sPath, $sType) Local $iSearch = FileFindFirstFile($sPath & "\*.*") If $iSearch = -1 Then Return SetError(1, 0, 0) Local $iFile, $iFullFile, $sRet, $i While 1 $iFile = FileFindNextFile($iSearch) If @error Then ExitLoop $iFullFile = $sPath & "\" & $iFile If StringInStr(FileGetAttrib($iFullFile), "D") Then $sRet = _GetOldFiles($iFullFile, $sType) For $i = 1 To $sType[0] If StringRight($iFullFile, 3) = $sType[$i] Then _SetFilesInfo($iFullFile) EndIf Next WEnd FileClose($iSearch) EndFunc Func _SetFilesInfo($sFile) Local $iDate, $iIndex Local $aCreateDate = FileGetTime($sFile, 1) $iDate = $aCreateDate[0] & "/" & $aCreateDate[1] & "/" & $aCreateDate[2] & " " & _ $aCreateDate[3] & ":" & $aCreateDate[4] & ":" & $aCreateDate[4] If _DateDiff("s", $iDate, _NowCalc()) >= $Age Then $iIndex = _GUICtrlListView_AddItem($hListView, $sFile) _GUICtrlListView_AddSubItem($hListView, $iIndex, $iDate, 1) EndIf EndFunc Func _DeleteFiles() Local $iCount = _GUICtrlListView_GetItemCount($hListView) If $iCount < 1 Then Return False Local $i For $i = 0 To $iCount - 1 If _GUICtrlListView_GetItemChecked($hListView, $i) = False Then ContinueLoop FileDelete(_GUICtrlListView_GetItemText($hListView, $i)) _GUICtrlListView_DeleteItem($hListView, $i) Next EndFunc Func _MsgBox($sFlag = 0, $sTitle = "", $sText = "", $hWnd = 0) Local $DllRet = DllCall("user32.dll", "int", "MessageBox", "hwnd", $hWnd, "str", $sText, "str", $sTitle, "int", $sFlag) Return $DllRet[0] EndFunc ;==>_MsgBox | Потестируй, у меня со временем не очень  |