Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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

get file name nodejs

var path = require('path');
var scriptName = path.basename(__filename);
Comment

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))
Comment

PREVIOUS NEXT
Code Example
Javascript :: get the first number of the integer in js 
Javascript :: find in highest value key from an object javascript 
Javascript :: cut array up javascript 
Javascript :: express set views directory 
Javascript :: get data in date filter sequelize 
Javascript :: js add id to element 
Javascript :: unix time to date javascript 
Javascript :: async function fetchJson 
Javascript :: javascript change webpage title 
Javascript :: multer file type validation 
Javascript :: yarn add material ui 
Javascript :: javascript Convert an array of strings to numbers 
Javascript :: play an audio at a specific volume in javascript 
Javascript :: split sentence including special characters javascript 
Javascript :: regex url 
Javascript :: remove duplicate strings from array javascript 
Javascript :: get child element by class javascript 
Javascript :: how to convert a string of numbers into an array javascript 
Javascript :: create react native app 
Javascript :: get count of div by class 
Javascript :: nesting for loops 
Javascript :: how to add comment in react js 
Javascript :: javascript detect click outside of element 
Javascript :: react native textinput turnoff capitalize first letter 
Javascript :: react router dom 6 go back 
Javascript :: vue truncate text 
Javascript :: javascript regex number 
Javascript :: Add table row in jQuery 
Javascript :: data-dismiss= modal in jquery 
Javascript :: javascript filter array of objects by id 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =