Answers for "read files in folder nodejs"

3

how to get file name in directory node js

const fs = require('fs')

const dir = '/Users/flavio/folder'
const files = fs.readdirSync(dir)

for (const file of files) {
  console.log(file)
}
Posted by: Guest on October-16-2020
5

node js get files in dir

const path = require('path');
const fs = require('fs');

fs.readdir(
  path.resolve(__dirname, 'MyFolder'),
  (err, files) => {
    if (err) throw err;
    
    for (let file of files) {
      console.log(file);
    }
  }
);
Posted by: Guest on September-07-2020
0

how to read all files in a folder in node js

fs.readdir('./', (err, files) => {
        files.forEach(file => {
        //   console.log(file);
        }});
Posted by: Guest on February-08-2021

Code answers related to "read files in folder nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language