import logging
from pathlib import Path


def get_filelist(paths: list[str], recursive: bool = False) -> list[str]:
    """Get a list of files (but not directories) from a path.

    Args:
        paths (list[str]): The path(s) to search for files.
        recursive (bool, optional): Whether to recursively search the path. Defaults to False.

    Returns:
        list[str]: A list of all filenames, given as absolute paths.
    """
    logger = logging.getLogger("checkr")
    filelist = []
    for path in paths:
        dir = Path(path)
        if not dir.exists():
            logger.error(f"The directory '{dir}' does not exist.")
        elif not dir.is_dir():
            logger.error(f"'{dir}' is not a directory.")
        else:
            results = dir.rglob("*") if recursive else dir.glob("*")
            filelist.extend([x for x in results if x.is_file()])
    return filelist