cramaboule Posted January 15, 2009 Posted January 15, 2009 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... My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
cramaboule Posted May 14, 2009 Author Posted May 14, 2009 #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... My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Hellooopsforgotsendcommand Posted November 22, 2009 Posted November 22, 2009 would it not be better to have temp files deleted from the windows dir only if they are older than a day. i.e. not that days files?
insignia96 Posted November 22, 2009 Posted November 22, 2009 ooooh I like the idea! Good idea for modification above tho. BRB. Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower
insignia96 Posted November 22, 2009 Posted November 22, 2009 (edited) expandcollapse popup#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 November 22, 2009 by insignia96 Netol and MarkIT 2 Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower
murray654 Posted January 23, 2010 Posted January 23, 2010 On 11/22/2009 at 8:02 AM, 'insignia96 said: That Should do it. I think Hi, Great script - I modified it to delete files older than 1 hour - do you foresee any problem with doing this?Another question; this script does not delete read only files - is this by design?Cheers,Murray
Splash Posted January 23, 2010 Posted January 23, 2010 Tiny and cool script. Good work guy. Automatic Update UDF - IP Address UDF - WinPcap AutoIt _FindDevice()[font="Verdana"][size="2"]AutoIt Spanish/Brasil/World community!!![/size][/font]Use you wanna a dot.tk domain please use my link:
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