Skip to content

Instantly share code, notes, and snippets.

@BrunoTorresF
Created March 21, 2019 00:18
Show Gist options
  • Save BrunoTorresF/9b9b347b51f9f29725d41908c2624d37 to your computer and use it in GitHub Desktop.
Save BrunoTorresF/9b9b347b51f9f29725d41908c2624d37 to your computer and use it in GitHub Desktop.
Counts file name occurances in directory [WIP]
const fs = require('fs');
if (process.argv.length <= 2) {
console.log('Usage: ' + __filename + ' path/to/directory');
process.exit(-1);
}
const path = process.argv[2];
fs.readdir(path, (err, items) => {
if (err) {
console.error(err);
process.exit(-1);
}
console.log(items);
for (var i = 0; i < items.length; i++) {
console.log(items[i]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment