import pathlib


def _get_name(basename, directory):
    """Get a name based on basename and extension that is not yet in the directory."""
    fpath = pathlib.Path("{}.tar.bz2".format(basename))
    num = 1
    while fpath in directory.iterdir():
        fpath = pathlib.Path("{}-{}.tar.bz2".format(basename, num))
        num += 1
    return directory / fpath