Better code to remove the file extention from a file path