def METHOD_NAME(
    directory_to_transfer, archive_directory, compressed=True, copy_all_files=False
):
    """
    Create an archive of jobs in directory_to_transfer.
    Args:
        directory_to_transfer (str): project directory with jobs to export
        archive_directory (str): name of the final archive; if no file ending is given .tar.gz is added automatically when needed
        compressed (bool): if True compress archive_directory as a tarball; default True
        copy_all_files (bool): if True include job output files in archive, otherwise just include .h5 files; default False
    """
    if archive_directory[-7:] == ".tar.gz":
        archive_directory = archive_directory[:-7]
        if not compressed:
            compressed = True
    if directory_to_transfer[-1] != "/":
        directory_to_transfer = os.path.basename(directory_to_transfer)
    else:
        directory_to_transfer = os.path.basename(directory_to_transfer[:-1])
    # print("directory to transfer: "+directory_to_transfer)
    if not copy_all_files:
        pfi = PyFileIndex(path=directory_to_transfer, filter_function=filter_function)
    else:
        pfi = PyFileIndex(path=directory_to_transfer)
    df_files = pfi.dataframe[~pfi.dataframe.is_directory]
    # Create directories
    dir_lst = generate_list_of_directories(
        df_files=df_files,
        directory_to_transfer=directory_to_transfer,
        archive_directory=archive_directory,
    )
    # print(dir_lst)
    for d in dir_lst:
        os.makedirs(d, exist_ok=True)
    # Copy files
    dir_name_transfer = getdir(path=directory_to_transfer)
    for f in df_files.path.values:
        copyfile(
            f,
            os.path.join(
                archive_directory,
                dir_name_transfer,
                os.path.relpath(f, directory_to_transfer),
            ),
        )
    if compressed:
        compress_dir(archive_directory)