Skip to content

Instantly share code, notes, and snippets.

@vilmibm
Created September 16, 2010 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vilmibm/582532 to your computer and use it in GitHub Desktop.
Save vilmibm/582532 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
sys = require('sys');
function walk(path, callback) {
var recur_or_cb = function( abspath ) {
return function(err, stats) {
if ( stats.isDirectory() )
walk(abspath, callback);
else
callback(err, abspath);
};
};
fs.readdir(path, function(err, files) {
files.forEach(function(f) {
abspath = path + '/' + f;
fs.stat(abspath, recur_or_cb(abspath));
});
});
}
walk('/home/nate/Music', function(err, path) { sys.print(path+"\n") });
@vilmibm
Copy link
Author

vilmibm commented Sep 16, 2010

I'm banking on the "n /'s are okay in Unix". An os.join parrallel would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment