Jump to content

Delete Temp Files


cramaboule
 Share

Recommended Posts

Here is a script to delete *.tmp files and and temporary folder.

An easy one !

#Include <File.au3>
#Include <Array.au3>

$Debug=0

Func EmptyFolder($FolderToDelete)
    $AllFiles=_FileListToArray($FolderToDelete,"*",0)
    If $Debug Then MsgBox(0,"",$FolderToDelete)
    If IsArray($AllFiles) Then
        If $Debug Then 
            _ArrayDisplay( $AllFiles,$FolderToDelete)
        EndIf
        For $i = 1 To $AllFiles[0]
            FileDelete($FolderToDelete & "\" & $AllFiles[$i])
            DirRemove($FolderToDelete & "\" & $AllFiles[$i], 1)    
        Next
    EndIf
EndFunc

EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files\Content.IE5")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files")
EmptyFolder (@HomeDrive & @HomePath & "\Cookies")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\History")
EmptyFolder (@HomeDrive & "\Temp\Temporary Internet Files")
EmptyFolder (@WindowsDir & "\Temp")
EmptyFolder (@HomeDrive & @HomePath & "\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Application Data\Microsoft\Office\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temp")

Cram...

Link to comment
Share on other sites

  • 3 months later...

#Include <File.au3>
#Include <Array.au3>

$Debug=0

Func EmptyFolder($FolderToDelete)
    $AllFiles=_FileListToArray($FolderToDelete,"*",0)
    If $Debug Then ConsoleWrite("-->" & $FolderToDelete & @CRLF )
    If IsArray($AllFiles) Then
        If $Debug Then 
            _ArrayDisplay( $AllFiles,$FolderToDelete)
        EndIf
        For $i = 1 To $AllFiles[0]
            $delete = FileDelete($FolderToDelete & "\" & $AllFiles[$i])
            If $Debug Then
                ConsoleWrite($FolderToDelete & "\" & $AllFiles[$i]& " =>"&$delete & @CRLF  )
            EndIf
            DirRemove($FolderToDelete & "\" & $AllFiles[$i], 1)    
        Next
    EndIf
EndFunc

EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files\Content.IE5")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files")
EmptyFolder (@HomeDrive & @HomePath & "\Cookies")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\History")
EmptyFolder (@HomeDrive & "\Temp\Temporary Internet Files")
EmptyFolder (@WindowsDir & "\Temp")
EmptyFolder (@HomeDrive & "\Temp")
EmptyFolder (@HomeDrive & @HomePath & "\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Application Data\Microsoft\Office\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temp")

ShellExecuteWait("RunDll32.exe"," InetCpl.cpl,ClearMyTracksByProcess 255")

Added the ShellExecuteWait then NOW the Temporary Internet Files are really deleted !

Cram...

Link to comment
Share on other sites

  • 6 months later...

#Include <File.au3>
#Include <Array.au3>

$Debug=1

Func EmptyFolder($FolderToDelete)
    $AllFiles=_FileListToArray($FolderToDelete,"*",0)
    If $Debug Then ConsoleWrite("-->" & $FolderToDelete & @CRLF )
    If IsArray($AllFiles) Then
        If $Debug Then
            _ArrayDisplay( $AllFiles,$FolderToDelete)
        EndIf
        For $i = 1 To $AllFiles[0]
            $crt = FileGetTime( $FolderToDelete & "\" & $AllFiles[$i], 1 )
            If $crt[2] = @MDAY And $crt[0] = @YEAR And $crt[1] = @MON Then
                If $Debug Then
                    ConsoleWrite( $FolderToDelete & "\" & $AllFiles[$i] & " --> Today's File, Skipping!" & @CRLF )
                EndIf
                ContinueLoop
            EndIF
            $delete = FileDelete($FolderToDelete & "\" & $AllFiles[$i])
            If $Debug Then
                ConsoleWrite($FolderToDelete & "\" & $AllFiles[$i]& " =>"&$delete & @CRLF  )
            EndIf
            DirRemove($FolderToDelete & "\" & $AllFiles[$i], 1)
        Next
    EndIf
EndFunc

EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files\Content.IE5")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temporary Internet Files")
EmptyFolder (@HomeDrive & @HomePath & "\Cookies")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\History")
EmptyFolder (@HomeDrive & "\Temp\Temporary Internet Files")
EmptyFolder (@WindowsDir & "\Temp")
EmptyFolder (@HomeDrive & "\Temp")
EmptyFolder (@HomeDrive & @HomePath & "\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Application Data\Microsoft\Office\Recent")
EmptyFolder (@HomeDrive & @HomePath & "\Local Settings\Temp")

ShellExecuteWait("RunDll32.exe"," InetCpl.cpl,ClearMyTracksByProcess 255")

That Should do it. I think :)

Edited by insignia96

Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

Link to comment
Share on other sites

  • 2 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...