Skip to content

Instantly share code, notes, and snippets.

@jasenmichael
Created December 29, 2018 03:01
Show Gist options
  • Save jasenmichael/0f1ce0184085069285b9e75b12545ad9 to your computer and use it in GitHub Desktop.
Save jasenmichael/0f1ce0184085069285b9e75b12545ad9 to your computer and use it in GitHub Desktop.
get-file-path-name-ext-javascript created by jasenmichael - https://repl.it/@jasenmichael/get-file-path-name-ext-javascript
var path = require('path')
let file = "path/to/file/file.ext"
let filePath = path.dirname(file)
let fileName = file.split('.').pop()
let fileNameWithExtention = file.split('/').pop()
console.log('file: ',file)
console.log('filePath: ',filePath)
console.log('fileName: ',fileName)
console.log('fileNameWithExtention: ',fileNameWithExtention)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment