from pathlib import Path


def BrukerListFiles(PATH,Recursive=False):
    """List all SPC (EMX) and DTA (Elixys) files in the PATH.  

    Args:
        PATH ([str]): path of the folder containing the Bruker files.
        Recursive (bool, optional): [to check the folder and subfolders]. Defaults to False.
    """      
    exts = [".DTA",".dta",".spc",".SPC"]
    if Recursive:
        files = [p for p in Path(PATH).rglob('*') if p.suffix in exts]
    else:
        files = [p for p in Path(PATH).iterdir() if p.suffix in exts]

    return(list(sorted(files)))