node package manager


Get an array of all files in a directory and subdirectories. Supports filters.


This is a fork of

It adds support for filtering files and folders.

A simple Node module for recursively listing all files in a directory, or in any subdirectories.

It does not list directories themselves.

npm install recursive-readdir-filter

Just like recursive-readdir

var recursive-readdir = require('recursive-readdir-filter');
recursive-readdir('some/path', function (err, files) {
  // Files is an array of filename 

But now with filters;

var options = {
    filterDir: function (stats) {
        return !== 'node_modules';
    filterFile: function (stats) {
recursive-readdir('some/path', options, function (err, files) {

Options are completly optional;

Both options must be a function. A Stats object is passed to them, but with some extra information added:

  • path: the full path to the file/folder. e.g. /Volumes/Home/foo.txt.
  • name: the name of file/folder. e.g foo.txt.
  • folder: the parent folder of the file/folder. e.g. /Volumes/Home.
  dev: 2114,
  ino: 48064969,
  mode: 33188,
  nlink: 1,
  uid: 85,
  gid: 100,
  rdev: 0,
  size: 527,
  blksize: 4096,
  blocks: 8,
  atime: Mon, 10 Oct 2011 23:24:11 GMT,
  mtime: Mon, 10 Oct 2011 23:24:11 GMT,
  ctime: Mon, 10 Oct 2011 23:24:11 GMT,
  name: 'a',
  path: '/Volumes/Home/Projects/recursive-readdir/test/testdir/a/a/'
  folder: '/Volumes/Home/Projects/recursive-readdir/test/testdir/a/'


Is run whenever a folder is found.


Is run whenever a file is found.