Netol Posted July 1 Share Posted July 1 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 Link to comment Share on other sites More sharing options...
AutoBert Posted July 2 Share Posted July 2 have a look in helfile -> directory macros: @Tempdir should help you. Link to comment Share on other sites More sharing options...
ioa747 Posted July 2 Share Posted July 2 #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 Link to comment Share on other sites More sharing options...
Netol Posted July 2 Author Share Posted July 2 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 Link to comment Share on other sites More sharing options...
ioa747 Posted July 2 Share Posted July 2 (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 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
Solution bdr529 Posted July 2 Solution Share Posted July 2 RunWait(@ComSpec & " /c " & 'rd /S /q %temp%', "", @SW_HIDE) ioa747 and Netol 2 To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
Netol Posted July 2 Author Share Posted July 2 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 Link to comment Share on other sites More sharing options...
Netol Posted July 2 Author Share Posted July 2 8 hours ago, bdr529 said: RunWait(@ComSpec & " /c " & 'rd /S /q %temp%', "", @SW_HIDE) this line command work fine Thanks a lot Link to comment Share on other sites More sharing options...
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