using path.extname and path.basename instead of string split.