Sign in to follow this  
Followers 0
Mucho

How to determine if file is older than n hours?

3 posts in this topic

I would like to determine if a file is older than 18 hours so that I can overwrite it. I know the keyword is filegettime but it is not so straightforward. Please help.

Share this post


Link to post
Share on other sites



I would like to determine if a file is older than 18 hours so that I can overwrite it. I know the keyword is filegettime but it is not so straightforward. Please help.

An example:

#include <Date.au3>
$FILE = FileOpenDialog("SELECT",@ScriptDir,"All (*.*)",1)
$TIME = FileGetTime($FILE,0,0)
$TIME1 = $TIME[0] & "/" & $TIME[1] & "/" & $TIME[2] & " " & $TIME[3] & ":" & $TIME[4] & ":" & $TIME[5]
$TIME2 = _NowCalc()
If _DateDiff("h",$TIME1,$TIME2) > 18 Then
    MsgBox(0,"","File can be overwrite")
Else
    MsgBox(0,"","File cannot be overwrite")
EndIf

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thank you very much, Andreik.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0