JoshG 0 Posted January 6, 2011 looking for help in deleting files by date or by date age(120 days) within a specific folder using a specific file type *.att Thanks!!! Share this post Link to post Share on other sites
4Eyes 10 Posted January 6, 2011 JoshG, First of all, let me be the first to say RTFM! Look up FileExists() and FileGetTime(). 4Eyes Share this post Link to post Share on other sites
JoHanatCent 13 Posted January 6, 2011 looking for help in deleting files by date or by date age(120 days) within a specific folder using a specific file type *.att Keep this as part of your list to read up on:FileOpenDialogFileFindFirstFileFileFindNextFileFileGetAttribFileDelete Share this post Link to post Share on other sites
Varian 8 Posted January 6, 2011 (edited) One way (of many):#include <Array.au3> #include <Date.au3> #include <File.au3> Local $Folder, $FileList, $FileType = '*.att', $ScavangeDate = 120 $Folder = FileSelectFolder('Choose The Diretory To Scavange For Old Files', '') If @error Then Exit $FileList = _FileListToArray($Folder, $FileType, 1) If @error Then Exit MsgBox(270352, 'Fatal Error', 'No "att" files in:' & @LF & $Folder) For $i = $FileList[0] To 1 Step -1 Local $FileDate = FileGetTime($Folder & '\' & $FileList[$i]) If IsArray($FileDate) Then Local $Date = $FileDate[0] & '/' & $FileDate[1] & '/' & $FileDate[2] & ' ' & $FileDate[3] & ':' & $FileDate[4] & ':' & $FileDate[5] If _DateDiff('D', $Date, _NowCalc()) >= $ScavangeDate Then ContinueLoop EndIf _ArrayDelete($FileList, $i) Next If UBound($FileList) - 1 = 0 Then Exit MsgBox(270352, 'Completed', 'No old "att" files in:' & @LF & $Folder) $FileList[0] = UBound($FileList) - 1 _ArrayDisplay($FileList, 'Old Files To Be Deleted') Local $Confirm = MsgBox(270628, 'Confirmation', 'Continue with File Deleteion(s)?') Select Case $Confirm = 6 ;Yes For $i = 1 To $FileList[0] FileRecycle($Folder & '\' & $FileList[$i]) Next Case $Confirm = 7 ;No EndSelect Edited January 6, 2011 by Varian Share this post Link to post Share on other sites
JoshG 0 Posted January 10, 2011 One way (of many):#include <Array.au3> #include <Date.au3> #include <File.au3> Local $Folder, $FileList, $FileType = '*.att', $ScavangeDate = 120 $Folder = FileSelectFolder('Choose The Diretory To Scavange For Old Files', '') If @error Then Exit $FileList = _FileListToArray($Folder, $FileType, 1) If @error Then Exit MsgBox(270352, 'Fatal Error', 'No "att" files in:' & @LF & $Folder) For $i = $FileList[0] To 1 Step -1 Local $FileDate = FileGetTime($Folder & '\' & $FileList[$i]) If IsArray($FileDate) Then Local $Date = $FileDate[0] & '/' & $FileDate[1] & '/' & $FileDate[2] & ' ' & $FileDate[3] & ':' & $FileDate[4] & ':' & $FileDate[5] If _DateDiff('D', $Date, _NowCalc()) >= $ScavangeDate Then ContinueLoop EndIf _ArrayDelete($FileList, $i) Next If UBound($FileList) - 1 = 0 Then Exit MsgBox(270352, 'Completed', 'No old "att" files in:' & @LF & $Folder) $FileList[0] = UBound($FileList) - 1 _ArrayDisplay($FileList, 'Old Files To Be Deleted') Local $Confirm = MsgBox(270628, 'Confirmation', 'Continue with File Deleteion(s)?') Select Case $Confirm = 6 ;Yes For $i = 1 To $FileList[0] FileRecycle($Folder & '\' & $FileList[$i]) Next Case $Confirm = 7 ;No EndSelect Thanks so much for the help!!!!! Share this post Link to post Share on other sites
kaotkbliss 146 Posted January 10, 2011 Why make a 2nd thread when you already got answered in the first? 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
AdmiralAlkex 125 Posted January 10, 2011 Why make a 2nd thread when you already got answered in the first?Look at the time. There were no answer then. And the other is (was) in the examples forums. Josh kinda messed up. .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 11, 2011 Oh, I only remember the other one that I replied to and didn't see this one until today. 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
senthil1986 0 Posted September 22, 2012 Hi Friends,Subject:- Required below AUTOIT script need to modify*.att file should be deleted with asking user (operator)must done automaticallycondition:- run on back ground does'nt affect other applicationthank you============================================================================#include <Array.au3>#include <Date.au3>#include <File.au3>Local $Folder, $FileList, $FileType = '*.att', $ScavangeDate = 120$Folder = FileSelectFolder('Choose The Diretory To Scavange For Old Files', '')If @error Then Exit$FileList = _FileListToArray($Folder, $FileType, 1)If @error Then Exit MsgBox(270352, 'Fatal Error', 'No "att" files in:' & @LF & $Folder)For $i = $FileList[0] To 1 Step -1 Local $FileDate = FileGetTime($Folder & '\' & $FileList[$i]) If IsArray($FileDate) Then Local $Date = $FileDate[0] & '/' & $FileDate[1] & '/' & $FileDate[2] & ' ' & $FileDate[3] & ':' & $FileDate[4] & ':' & $FileDate[5] If _DateDiff('D', $Date, _NowCalc()) >= $ScavangeDate Then ContinueLoop EndIf _ArrayDelete($FileList, $i)NextIf UBound($FileList) - 1 = 0 Then Exit MsgBox(270352, 'Completed', 'No old "att" files in:' & @LF & $Folder)$FileList[0] = UBound($FileList) - 1_ArrayDisplay($FileList, 'Old Files To Be Deleted')Local $Confirm = MsgBox(270628, 'Confirmation', 'Continue with File Deleteion(s)?')Select Case $Confirm = 6 ;Yes For $i = 1 To $FileList[0] FileRecycle($Folder & '\' & $FileList[$i]) Next Case $Confirm = 7 ;NoEndSelect=============================================================================== Share this post Link to post Share on other sites