Answers for "get how many files in a folder fs"

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
2

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))
Posted by: Guest on October-16-2020
0

number all files in a folder

a=1
for i in *.jpg; do
  new=$(printf "%04d.jpg" "$a") #04 pad to length of 4
  mv -i -- "$i" "$new"
  let a=a+1
done
Posted by: Guest on June-17-2020
0

number all files in a folder

ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done
Posted by: Guest on June-17-2020

Code answers related to "get how many files in a folder fs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language