JoshG Posted January 6, 2011 Share Posted January 6, 2011 Hi hoping i might get some help on this... I'm looking for a way to delete files by date i.e. delete any files older then a specified date or number of days older then system date files older then 120 days... within a specific folder and with specific file type Thanks in advam\nce Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 6, 2011 Share Posted January 6, 2011 "This is not a general support forum!" .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 6, 2011 Share Posted January 6, 2011 I haven't tested this, but it should do what you want. To test it, I would change FileDelete to something else, maybe write the files to a text file or something so you can check and make sure it works correctly before actually deleting files. Also, you will have to put your own path in. #include <Date.au3> #Include <File.au3> $files = _FileListToArray("Your path here", "*.ext", 2) ;create an array of files in the specified folder $date=@YEAR&"/"&@MON&"/"&@MDAY;getting the current date $newdate=_DateAdd("D",-120,$date) ;adding -120 days (subtract 120 days) $formatdate=StringSplit($newdate,"/") ;removing the / $newdate=$formatdate[1]&$formatdate[2]&$formatdate[3]&@HOUR&@MIN&@SEC ;putting the date back together in a format easily compared to the FileGetTime func If IsArray($files) Then ;Making sure an array was created For $i = 1 To UBound($files) - 1 ;Loop through all the files found $aTime = FileGetTime("Your path here" & $files[$i], 1, 1) ;get the creation time of the file If $aTime < $newdate Then ;check to see if creation time is older than 120 days FileDelete($files[$i]) ;delete the file if it is EndIf Next EndIf 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Varian Posted January 6, 2011 Share Posted January 6, 2011 (edited) I actually answered your question in your PREVIOUS TOPIC OF THE SAME NAMELook Edited January 6, 2011 by Varian 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