from pathlib import Path


def get_file_path(path: Path, fn: str) -> Path:
    """
    Find an available path for a file, using an index prefix.

    Parameters
    ----------
    path: Path
        file path
    fn: str
        filename

    Returns
    ----------
    path
        file path
    """
    paths = path.glob(f"*_{fn}")
    max_index = max((int(p.name.split("_")[0]) for p in paths), default=-1) + 1
    return path / f"{max_index}_{fn}"