find_files
- ketos.data_handling.data_handling.find_files(path, substr, return_path=True, search_subdirs=False, search_path=False)[source]
Find all files in the specified directory containing the specified substring in their file name
- Args:
- path: str
Directory path
- substr: str
Substring contained in file name
- return_path: bool
If True, path to each file, relative to the top directory. If false, only return the filenames
- search_subdirs: bool
If True, search all subdirectories
- search_path: bool
Search for substring occurrence in relative path rather than just the filename
- Returns:
- files: list (str)
Alphabetically sorted list of file names
- Examples:
>>> from ketos.data_handling.data_handling import find_files >>> >>> # Find files that contain 'super' in the name; >>> # Do not return the relative path >>> find_files(path="ketos/tests/assets", substr="super", return_path=False) ['super_short_1.wav', 'super_short_2.wav'] >>> >>> # find all files with '.h5" in the name >>> # Return the relative path >>> find_files(path="ketos/tests/", substr="super", search_subdirs=True) ['assets/super_short_1.wav', 'assets/super_short_2.wav']