- Published on
Read files names
Required: node.js
installation.
Quickly get all files' names inside a folder
$ console.log(fs.readdirSync('./folder-path'))
Example:
# Make sure node.js installed$ node -vv14.17.0
# Now it's good to go$ node> console.log(fs.readdirSync('./folder'))[ '.DS_Store', 'authors', 'blog', 'headerNavLinks.js', 'logo.svg', 'projectsData.js', 'siteMetadata.js', 'snippets']