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.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.