mlglobal Posted August 2, 2005 Posted August 2, 2005 I've used AutoIT for a long time and find it extremely user friendly. I've picked up tips and tricks from the forum and wanted to post a solution I just got hammered out. Nothing original as I copied most of the code from the help file. It works great though. I left the Msgbox's in but commented out to keep it easy to troubleshoot. ; ----------------------------------------------------------------------------; Script Start; ----------------------------------------------------------------------------$CurrentDirectory = FileChangeDir("E:\DWC\EDI\EDI File Archive") ; Changes the current working directory to the one needed; MsgBox(0, "", "Current Working Directory: " & @WORKINGDIR) ; Used for viewing the output of variable#include <Date.au3> ; Using the Date.au3 file for reference library.$TodaysDateIs = (@YEAR & "/" & @MON & "/" & @MDAY) ; Sets up the date format for calculation, must use Year, month, day format; MsgBox(0, "", "The Date is: " & $TodaysDateIs ) ; Used for viewing the output of variable; Shows the filenames of all files in the current directory, note that "." and ".." are returned.$search = FileFindFirstFile("*") ; Check if the search was successfulIf $search = -1 Then ; MsgBox(0, "Error", "No files/directories matched the search pattern") ExitEndIfWhile 1 $file = FileFindNextFile($search) If @error Then ExitLoop If $file = "." Then ContinueLoop ; Blocks output of the root directory "." If $file = ".." Then ContinueLoop ; Blocks output of the current directory ".." $FileDate = FileGetTime($file, 0, 0) ; MsgBox(0, "File Date is: ", $FileDate) ; MsgBox(0, "File Name is: ", $file) If Not @error then $yyyymmdd = $FileDate[0] & "/" & $FileDate[1] & "/" & $FileDate[2] ; MsgBox(0, "File Date is", $yyyymmdd) EndIf $DateDiffTotal = _DateDiff( 'D',$yyyymmdd,$TodaysDateIs) ; MsgBox(0, "", "Difference in Days: " & $DateDiffTotal ) ; Used for viewing the output of variable If $DateDiffTotal > 31 Then ; MsgBox(0, "", $file & " is " & $DateDiffTotal & " days old and will be DELETED") FileDelete($file) ; Actual delete statement. Else ; MsgBox(0, "", $file & " is " & $DateDiffTotal & " days old and will be retained") EndIf WEnd; Close the search handleFileClose($search)
Developers Jos Posted August 7, 2005 Developers Posted August 7, 2005 Here is a script example that can delete files older than and remove empty directories i posted a while ago... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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