Skip to content

Instantly share code, notes, and snippets.

@TimJMartin
Created April 28, 2016 08:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimJMartin/77148741d1d2f91e9007e03ff38ea72b to your computer and use it in GitHub Desktop.
Save TimJMartin/77148741d1d2f91e9007e03ff38ea72b to your computer and use it in GitHub Desktop.
NodeJS Script for finding just zip files from a path
//Code snipped to use recursive-readdir to provide a list of required file types.
var path = require('path');
var recursive = require('recursive-readdir');
function ignoreFunc(file, stats) {
// `file` is the absolute path to the file and we can use extname to look at the file extension
return stats.isFile() && path.extname(file) != ".zip";
}
// Ignore files using the ignroeFunc
recursive('/somePath/', [ignoreFunc], function (err, files) {
// Files is an array of filename
console.log(files);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment