Fix trailing space before extensions in filename