def unique_path(path):
    """Generate an unused filename that looks like `path`"""
    # this adds ".1", ".2" etc. before the extension
    orig_suffix = path.suffix
    orig_name = path
    number = 1
    while path.exists():
        path = orig_name.with_suffix(f'.{number}{orig_suffix}')
        number += 1
    return path