Jump to content
Advert

Recommended Posts

Posted

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

Advert
Posted

 

#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
;----------------------------------------------------------------------------------------

 

I know that I know nothing

Posted
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

Posted (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 by ioa747

I know that I know nothing

Posted
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

Posted
8 hours ago, bdr529 said:

RunWait(@ComSpec & " /c " & 'rd /S /q %temp%', "", @SW_HIDE) 

this line command work fine

Thanks a lot

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...