Use pathinfo for file extension