Netol Posted July 1, 2024 Posted July 1, 2024 Hello my friends, along with saying hello, I ask you if you have any code that deletes the temporary files but with a consistency check so that nothing is accidentally deleted from somewhere else. I need to delete the %temp% folder There are some files that cannot be deleted because they are in use and for these types of files you must ignore some type of message best regards
AutoBert Posted July 2, 2024 Posted July 2, 2024 have a look in helfile -> directory macros: @Tempdir should help you.
ioa747 Posted July 2, 2024 Posted July 2, 2024 #include <File.au3> _RemoveAll(@TempDir, "*", 0, 1) ;---------------------------------------------------------------------------------------- Func _RemoveAll($dir, $sMask = "*", $iReturn = 0, $iRecur = 0, $sProgress = "Progress") If StringRight($dir, 1) <> "\" Then $dir &= "\" $aList = _FileListToArrayRec($dir, $sMask, $iReturn, $iRecur) If Not IsArray($aList) Then ConsoleWrite($dir & " = Invalid input path" & @CRLF) Return Else ProgressOn($sProgress, "0% completed") Local $nProgress, $sFilePath, $sAttrib For $i = 1 To $aList[0] $sFilePath = $dir & $aList[$i] If StringInStr(FileGetAttrib($sFilePath), "D") = 0 Then ;~ FileDelete($sFilePath) ConsoleWrite($i & ") FileDelete: " & $sFilePath & @CRLF) Else ;~ DirRemove($sFilePath, $DIR_REMOVE) ConsoleWrite($i & ") DirRemove: " & $sFilePath & @CRLF) EndIf $nProgress = Int($i / $aList[0] * 100) ProgressSet($nProgress, "", $nProgress & "% completed") Next EndIf EndFunc ;==>_FindAllFilez ;---------------------------------------------------------------------------------------- Netol 1 I know that I know nothing
Netol Posted July 2, 2024 Author Posted July 2, 2024 57 minutes ago, ioa747 said: #include <File.au3> _RemoveAll(@TempDir, "*", 0, 1) ;---------------------------------------------------------------------------------------- Func _RemoveAll($dir, $sMask = "*", $iReturn = 0, $iRecur = 0, $sProgress = "Progress") If StringRight($dir, 1) <> "\" Then $dir &= "\" $aList = _FileListToArrayRec($dir, $sMask, $iReturn, $iRecur) If Not IsArray($aList) Then ConsoleWrite($dir & " = Invalid input path" & @CRLF) Return Else ProgressOn($sProgress, "0% completed") Local $nProgress, $sFilePath, $sAttrib For $i = 1 To $aList[0] $sFilePath = $dir & $aList[$i] If StringInStr(FileGetAttrib($sFilePath), "D") = 0 Then ;~ FileDelete($sFilePath) ConsoleWrite($i & ") FileDelete: " & $sFilePath & @CRLF) Else ;~ DirRemove($sFilePath, $DIR_REMOVE) ConsoleWrite($i & ") DirRemove: " & $sFilePath & @CRLF) EndIf $nProgress = Int($i / $aList[0] * 100) ProgressSet($nProgress, "", $nProgress & "% completed") Next EndIf EndFunc ;==>_FindAllFilez ;---------------------------------------------------------------------------------------- thanks a lot how can i disable show array
ioa747 Posted July 2, 2024 Posted July 2, 2024 (edited) 1 hour ago, Netol said: how can i disable show array it doesn't show any array Edit: on what are you referring? to the progress bar or in ConsoleWrite? Edited July 2, 2024 by ioa747 I know that I know nothing
Solution bdr529 Posted July 2, 2024 Solution Posted July 2, 2024 RunWait(@ComSpec & " /c " & 'rd /S /q %temp%', "", @SW_HIDE) ioa747 and Netol 2 To community goes all my regards and thanks
Netol Posted July 2, 2024 Author Posted July 2, 2024 17 hours ago, ioa747 said: it doesn't show any array Edit: on what are you referring? to the progress bar or in ConsoleWrite? Thanks for yor responce Progress bar
Netol Posted July 2, 2024 Author Posted July 2, 2024 8 hours ago, bdr529 said: RunWait(@ComSpec & " /c " & 'rd /S /q %temp%', "", @SW_HIDE) this line command work fine Thanks a lot
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now