Created
March 21, 2019 00:18
-
-
Save BrunoTorresF/9b9b347b51f9f29725d41908c2624d37 to your computer and use it in GitHub Desktop.
Counts file name occurances in directory [WIP]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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