Created
February 26, 2015 21:32
-
-
Save stewartduffy/f6b774deeb8ed735db29 to your computer and use it in GitHub Desktop.
JS function to get file name (without path or file extention)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileName = function(filePath) { | |
var filename = filePath.split("/"); | |
return filename[filename.length - 1].replace(/\.[^/.]+$/, ""); | |
}; | |
var filePath = "/downloads/tm/logos/IMG_30012014_185815.png"; | |
console.log( fileName(filePath) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment