use pathname to extract extname