how to get the name of all files in a folder nodejs code example
Example 1: node get all files in folder
fs.readdir('./', (err, files) => {
files.forEach(file => {
// console.log(file);
})});
Example 2: how to get file name in directory node js
const path = require('path')
//...
//inside the `for` loop
const stat = fs.lstatSync(path.join(dir, file))