def sanitizeFilename(filename: str) -> str:
    """
    Remove invalid characters <>:"/\\|?* from the filename.
    """
    result = ''
    for c in filename:
        if c not in '<>:"/\\|?*':
            result += c
    return result