Hi,
Found the wonderful Node-red a couple of months ago and have managed to automate my house with a Raspberry Pi, Telldus duo and a couple of cameras.
The cameras FTPs their files to the Raspberry where Node-Red is running.
One D-link camera creates subdirectories for each day and hour before storing. I've googled a lot and that seems to be the only way for it to store files.
I want Node-red to e-mail and send pushbullet-notifications when a file is stored but since the included core watch-node does not work recursively I'm stuck.
I thought of one approach to build the input parameter to the watch-node as a flow-variable depending on the time being but it doesn't look like you can have the argument to a node as a variable.
My next try was to use the node-watch package which defaults to recursive mode,
https://www.npmjs.com/package/node-watchI tired it first as a stand alone like this:
var watch = require('/usr/local/lib/node_modules/node-watch');
watch('/home/pi/FTP/Cameras/inhouse1/20170202/15', function(filename) {
if( /\.mp4$/.test(filename)) {
node.log(filename, ' changed.');
}
});
Works perfectly.
So here is what I did.
1. cd to .node-red
2.
npm install node-watchThat command seems to added the a directory named node-watch in the node_modules directory and also added the a row in the settings.js filelooking like
watch:require('node-watch') which I found out should make it possible to use it in a function.
3. Then I added a function node with the following code connected to a debug-node and triggered by a inject node every 3rd second

Code in the function-node looks like:
var watch = global.get('watch');
watch('/home/pi/FTP/Cameras/inhouse1/20170202/15', function(filename) {
msg.payload=filename+' changed.';
return msg;
});
It never triggers whatever I do in the directory....any suggestions on how to proceed?
One more question from a Javascript rookie,
Isn't this code going to create a new watch-object every 3rd second which will result in a lot of them being created after a couple of days resulting in memory problems?
brgds
Andreas