import pathlib


def make_file_name(directory, folder, extension):
    """Get a legal file name and return a Path object."""

    # replace "/*. " with "_"
    folder_mod = folder.translate({47: 95, 42: 95, 46: 95, 32: 95})

    return pathlib.Path(directory).joinpath(
        folder_mod + (("." + extension) if extension else "")
    )