find_files#
- find_files(names: list | str, root_paths: list | str | CloudPath | Path, max_nof_files: int = -1, get_as_str: bool = False) list | str [source]#
Deprecated since version 1.30.0: Import it from
sertit.path
instead ofsertit.files
Returns matching files recursively from a list of root paths.
Regex are allowed (using glob)
- Parameters:
- Returns:
File name
- Return type:
Examples
>>> root_path = 'D:/root' >>> dir1_path = 'D:/root/dir1' >>> dir2_path = 'D:/root/dir2' >>> >>> os.listdir(dir1_path) ["haha.txt", "huhu.txt", "hoho.txt"] >>> os.listdir(dir2_path) ["huhu.txt", "hehe.txt"] >>> >>> find_files("huhu.txt", root_path) ['D:/root/dir1/huhu.txt', 'D:/root/dir2/huhu.txt'] >>> >>> find_files("huhu.txt", root_path, max_nof_files=1) ['D:/root/dir1/huhu.txt']
>>> find_files("huhu.txt", root_path, max_nof_files=1, get_as_str=True) found = 'D:/root/dir1/huhu.txt'