For example, assuming that x = filename.jpg, I want to get filename, where filename could be any file name (Let\'s assume the file nam
x = filename.jpg
filename
In Node.js versions prior to 0.12.x:
path.basename(filename, path.extname(filename))
Of course this also works in 0.12.x and later.