node js get files in dir
//requiring path and fs modules
const path = require('path');
const fs = require('fs');
//joining path of directory
const directoryPath = path.join(__dirname, 'Documents');
//passsing directoryPath and callback function
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
}
//listing all files using forEach
files.forEach(function (file) {
// Do whatever you want to do with the file
console.log(file);
});
});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);
}
}
);
Also in JavaScript:
- aes 256 nodejs
- node red reverse proxy for ui to root
- javascript ajax post send an object
- js array sum
- how pass data from body in koa js
- javascript reverse a string
- filter in react native video
- javascript iterate through a binary tree
- data binding on checkbox angular
- javascript test if it is an array
- hex string to int javascript
- bootstrap 3 min max price range slider
- javascript falsy values
- js match true false
- define an unsigned int js
- variables 2 python .Bartolome sintes Marco
- vscode new file shortcut
- sleep javascript
- has own propriety javascrip
- react social login buttons
- jquery enforce important
- js set iframe src
- remove a class after 100 milliseconds jquery
- react admin newrecords.foreach is not a function