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

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 :: convert functoin with call back to promise 
Javascript :: node js util promisify 
Javascript :: remove all spaces from string javascript 
Javascript :: check overflow react 
Javascript :: select random from an array 
Javascript :: display am pm in javascript 
Javascript :: nodejs readdir 
Javascript :: if button is pressed js 
Javascript :: cancel settimeout 
Javascript :: drupal 8 get node from path alias 
Javascript :: array filter falsy values 
Javascript :: javascript thousand separator 
Javascript :: get only day from date in javascript 
Javascript :: javascript new date 30 days ago 
Javascript :: javascript password validation regex test 
Javascript :: get middle of string js 
Javascript :: append sibling javascript after first child 
Javascript :: what is niceScroll 
Javascript :: js omit last string 
Javascript :: validate age javascript 
Javascript :: javascript is JSON string valid 
Javascript :: express js server 
Javascript :: browser javascript update url without changing history 
Javascript :: rgb to hex js 
Javascript :: angular string contains 
Javascript :: react native get navigation bar height 
Javascript :: jquery 3.6.0 cdn 
Javascript :: change url with javascript after 5 seconds 
Javascript :: router.query is undefined in first render 
Javascript :: javascript infinite loop 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =