Using Current Date of file in relevance

Currently I have relevance verifying that a items.txt file exists before it runs

exists file "/beanstore-client/dg/util/Monitoring_Tool/items.txt"

What I am trying to do now is verify the items.txt file has the current date as well as existing and I wasn’t sure how to use the current date would it be something like this?:

exists file "/beanstore-client/dg/util/Monitoring_Tool/items.txt" and current date of it as time

What date do you want to check? The time the file was modified, or does the text of the file contain a date/time you wish to examine?

Maybe something like this?

Q: modification time of file "C:\tmp\test.ps1"
A: Thu, 17 Nov 2022 16:43:26 +0000
T: 1371

Q: now - modification time of file "C:\tmp\test.ps1"
A: 5 days, 23:53:57
T: 998

I want to always check the current date is the creation date of the file as we get a fresh batch of items.txt files every day so anything older than today’s date isn’t relevant.

Q: now - modification time of file “C:\tmp\test.ps1” < 1*day
A: True
T: 1603

This would give you a true or false on whether the file was modified in the last day

So something like this should be true if the file was created today correct? :

exists file "/beanstore-client/dg/util/Monitoring_Tool/items.txt" and modification time of file "/beanstore-client/dg/util/Monitoring_Tool/items.txt" < 1*day

Exactly that :slight_smile: or you could use creation time

Q: exists file “C:\tmp\test.ps1” and now - creation time of file “C:\tmp\test.ps1” < 1*day
A: False
T: 1241

Very close - you still have to subtract the modification time from “now” to see whether it’s less than a day old.

To save a little typing I’d use a whose() clause to filter

exists file "/beanstore-client/dg/util/Monitoring_Tool/items.txt" whose (now -  modification time of it  < 1 * day)

If the file needs to be dated today (as opposed to less than 24 hours old)

exists file "/beanstore-client/dg/util/Monitoring_Tool/items.txt" whose (modification time of it as universal date = current date)