Scan a directory
var path = require('path');
var fs = require('fs');
var dirPath = path.join(__dirname, 'files');
fs.readdir(dirPath, function (err, files) {
if (err) {
return console.log('Unable to scan dir ' + err);
}
files.forEach(function (file) {
// Do something with the file.
console.log(file);
});
});