JoshG Posted January 6, 2011 Share 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!!! Link to comment Share on other sites More sharing options...
4Eyes Posted January 6, 2011 Share Posted January 6, 2011 JoshG, First of all, let me be the first to say RTFM! Look up FileExists() and FileGetTime(). 4Eyes Link to comment Share on other sites More sharing options...
JoHanatCent Posted January 6, 2011 Share 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 Link to comment Share on other sites More sharing options...
Varian Posted January 6, 2011 Share 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 Link to comment Share on other sites More sharing options...
JoshG Posted January 10, 2011 Author Share 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!!!!! Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 10, 2011 Share Posted January 10, 2011 Why make a 2nd thread when you already got answered in the first? 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...
AdmiralAlkex Posted January 10, 2011 Share 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 Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 11, 2011 Share Posted January 11, 2011 Oh, I only remember the other one that I replied to and didn't see this one until today. 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...
senthil1986 Posted September 22, 2012 Share 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=============================================================================== 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