(node v8.x)
const path = require('path'); const filePath = 'hoge/fuga/moge.png'; console.info(path.basename(filePath)); console.info(path.dirname(filePath)); const ext = path.extname(filePath); console.info(ext); console.info(path.basename(filePath, ext)); //moge.png //hoge/fuga //.png //moge