Roman Posted July 14, 2006 Share Posted July 14, 2006 Hi I'm (still) quite new with AutoIt and i wonder how i can recognize files with a specific age, e.g. all files older than 3 hours, or all files older than 5 days and so on (allways refering to atribute "modifyed") How should i script this? :"> Thanks for every hint. Roman. Link to comment Share on other sites More sharing options...
Briegel Posted July 14, 2006 Share Posted July 14, 2006 Not sure but it must be possible with ExtProp.au3 from Simucal. Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 14, 2006 Share Posted July 14, 2006 Hi, FileGetTime() will be enough, I guess. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Marc Posted July 14, 2006 Share Posted July 14, 2006 For example: Local $pattern = "*.*" Local $file Local $handle $handle = FileFindFirstFile($pattern) If $handle = -1 Then MsgBox(4096, "Error", "No Files found!") Exit EndIf $list="" While 1 $file = FileFindNextFile($handle) If @error Then ExitLoop If $file <> "." And $file <> ".." Then If Not StringInStr(FileGetAttrib($file), "D") Then; not a directory $time = FileGetTime($file,0,1) $now = @YEAR & @MON & @MDAY & (@HOUR-3) & @MIN & @SEC if $time < $now Then $list = $list & $file & @CRLF EndIf EndIf EndIf Wend FileClose($handle) MsgBox(0,"Files older 3 hours",$list) have fun, Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
Roman Posted July 14, 2006 Author Share Posted July 14, 2006 (edited) For example: ... ... $now = @YEAR & @MON & @MDAY & (@HOUR-3) & @MIN & @SEC ... ... have fun, Marc Thanks, but is "@HOUR-3" a good idea? E.g. if i have one a clock in the night, with "@HOUR-3" i get a "-2" Then i get probably a non-numeric string within "$now" who cannot by compared with a number, or am i wrong? I searched too and found the UDFs _DateAdd und _DateDiff; i think they could be a solution for me because the enable me to calculate dates and times. Thanks, Roman. Edited July 14, 2006 by roman Link to comment Share on other sites More sharing options...
Briegel Posted July 14, 2006 Share Posted July 14, 2006 I think you don't need the two UDF's. '_DateDiff() ' and '_DateAdd ()' can you find in the 'User Defined Function - Date Management' in helpfile. You only have to include 'Date.au3'. #include <Date.au3> Briegel Link to comment Share on other sites More sharing options...
Marc Posted July 14, 2006 Share Posted July 14, 2006 Thanks, but is "@HOUR-3" a good idea? E.g. if i have one a clock in the night, with "@HOUR-3" i get a "-2"Then i get probably a non-numeric string within "$now" who cannot by compared with a number, or am i wrong?Oops, forgot to mention it ... you're right of course. There has to be a check if the number gets negative, add +24 hours and step one day back (checking for "walking back a month this way" and even, on the 1st of January, changing back to the last year.)So I'd suggest to use _dateAdd() instead Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) 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