Skip to content

Instantly share code, notes, and snippets.

@nash403
Created May 27, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nash403/de5d48586ff759fd653930a5b53223f9 to your computer and use it in GitHub Desktop.
Save nash403/de5d48586ff759fd653930a5b53223f9 to your computer and use it in GitHub Desktop.
List file names in current directory (without extension)
const fs = require('fs')
const path = require('path')
const files = []
fs.readdirSync(__dirname).forEach(file => {
const i = file.indexOf(path.basename(file))
const j = file.indexOf(path.extname(file))
files.push(file.substring(i, j))
})
console.log(JSON.stringify(files, null, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment