How can I count the number of files in a directory using nodejs with just plain JavaScript or packages? I want to do something like this:
nodejs
How to count the n
Okay, I got a bash script like approach for this:
const shell = require('shelljs') const path = require('path') module.exports.count = () => shell.exec(`cd ${path.join('path', 'to', 'folder')} || exit; ls -d -- */ | grep 'page-*' | wc -l`, { silent:true }).output
That's it.