Skip to content

Instantly share code, notes, and snippets.

@stewartduffy
Created February 26, 2015 21:32
Show Gist options
  • Save stewartduffy/f6b774deeb8ed735db29 to your computer and use it in GitHub Desktop.
Save stewartduffy/f6b774deeb8ed735db29 to your computer and use it in GitHub Desktop.
JS function to get file name (without path or file extention)
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