Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node get all files in folder

fs.readdir('./', (err, files) => {
    files.forEach(file => {
    //   console.log(file);
})});
Comment

node list files in directory


//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); 
    });
});
Comment

javascript get list of files in directory

var fs = require('fs');
var files = fs.readdirSync('/downloads');
Comment

PREVIOUS NEXT
Code Example
Javascript :: add url query in js 
Javascript :: get the first day and last day of current mongth javascript 
Javascript :: Select at random from array 
Javascript :: yup email validation 
Javascript :: javascript get element width and height 
Javascript :: get every member of a server discord js 
Javascript :: foreach document.getelementsbyclassname 
Javascript :: text number of lines react native 
Javascript :: js match alphabet 
Javascript :: how to adjust the caledar height fullcalendar 
Javascript :: object to url params js 
Javascript :: Remove line breaks with JavaScript 
Javascript :: javascript convert float to int 
Javascript :: jquery datepicker no past dates 
Javascript :: get window width jquery 
Javascript :: javascript find file extension from string 
Javascript :: python print pretty json 
Javascript :: disable console log alert eslint 
Javascript :: strike react native 
Javascript :: console.log ejs 
Javascript :: enzyme adapter react 17 
Javascript :: how to download image in canvas javascript as named 
Javascript :: js this binding setinterval 
Javascript :: path.split is not a function react hook use form 
Javascript :: nangular make window available 
Javascript :: angular limit string length 
Javascript :: jquery if null or empty 
Javascript :: array of A-Z 
Javascript :: random date generator javascript 
Javascript :: on change jquery 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =