JoshG 0 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 Share this post Link to post Share on other sites
AdmiralAlkex 125 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 Share this post Link to post Share on other sites
kaotkbliss 146 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 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
Varian 8 Posted January 6, 2011 (edited) I actually answered your question in your PREVIOUS TOPIC OF THE SAME NAMELook Edited January 6, 2011 by Varian Share this post Link to post Share on other sites