1 Use node.js library "chokidar"
2 Detail code:

varwatcher=chokidar.watch("/home/camille/Downloads",{ignored:/[\/\]./,persistent:true});varlog=console.log.bind(console);watcher.on('add',function(path){log('File',path,'hasbeenadded');}).on('addDir',function(path){log('Directory',path,'hasbeenadded');}).on('change',function(path){log('File',path,'hasbeenchanged');}).on('unlink',function(path){log('File',path,'hasbeenremoved');}).on('unlinkDir',function(path){log('Directory',path,'hasbeenremoved');}).on('error',function(error){log('Errorhappened',error);}).on('ready',function(){log('Initialscancomplete.Readyforchanges.');}).on('raw',function(event,path,details){log('Raweventinfo:',event,path,details);})

3 Log:
File /home/camille/Downloads/dd has been added
File /home/camille/Downloads/Untitled Document has been removed
Raw event info: rename dd { watchedPath: '/home/camille/Downloads' }
Raw event info: rename dddd { watchedPath: '/home/camille/Downloads' }
Raw event info: rename dd { watchedPath: '/home/camille/Downloads/dd' }
File /home/camille/Downloads/dddd has been added
File /home/camille/Downloads/dd has been removed