Function or Node to get the modified date from a file

Hi
I need to look at this file, and if it's modified within the last 2 sec. then that will run a flow.
/config/www/snapshots/foran_detection_latest.jpg

I just don't know where to start with a function or what Node too use, in my case.

Can someone guide me ?

Hi and welcome.

Have you tried the watch node?

Hi and Thx. :slight_smile:

Is it this one ?
node-red-contrib-watchdirectory (node) - Node-RED

Then yes and can see that i can "Type event : update" but how do I look at it and see if it's within 3 sec. from now ?

Ahh the build-in watch, no..
I add the filepath and filename to the name, and then i'm stuck.

The watch node is a core node and pre installed, you can watch for any changes to a file. So if a file is updated the watch node should catch it. No need to wait 3 seconds.

Add a debug then update the file and see what you get in the debug node.

@E1cid
What... :slight_smile:
Was it so easy... sry then... but then I hope I can ask in addition to this.
Can see the debug note gives me 7..

2/17/2021, 2:05:12 PMnode: 5d07bda.8a8d144/config/www/snapshots/terrasse_detection_latest.jpg : msg.payload : string[51]

"/config/www/snapshots/terrasse_detection_latest.jpg"

That will trigger a flow 7 time for the same update.. right?
If so, how do I get it to run only once for each update.

Filter msg using trigger node, to only receive one.
e.g.

[{"id":"dfed8e71.e5e8c8","type":"trigger","z":"5a245aa1.510164","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"250","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":360,"y":1760,"wires":[["3f35d274.99189e"]]},{"id":"cda23beb.ee4ea","type":"split","z":"5a245aa1.510164","name":"simulate 7 msg","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":390,"y":1700,"wires":[["dfed8e71.e5e8c8"]]},{"id":"3f35d274.99189e","type":"debug","z":"5a245aa1.510164","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":1760,"wires":[]},{"id":"7e3a17af.07e5","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,1,1,1,1,1,1]","payloadType":"json","x":150,"y":1680,"wires":[["cda23beb.ee4ea"]]}]

wow thx. it helped alot, and is working...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.