Extracts max chars in name truncated to nearest word

    :param name: path to edit
    :param max_chars: max chars of new name
    :param blank: char that represents the blank between words
    :return: Name edited to contain at most max_chars

def extract_name_max_chars(name, max_chars=64, blank=" "):
    """Extracts max chars in name truncated to nearest word

    :param name: path to edit
    :param max_chars: max chars of new name
    :param blank: char that represents the blank between words
    :return: Name edited to contain at most max_chars
    """
    new_name = name.strip()
    if len(new_name) > max_chars:
        new_name = new_name[:max_chars]  # get at most 64 chars
        if new_name.rfind(blank) > 0:
            new_name = new_name[:new_name.rfind(blank)]  # nearest word
    return new_name