vak.common.files.files.from_dir#

vak.common.files.files.from_dir(dir_path: str | Path, ext: str) list[str][source]#

Gets all files with a given extension from a directory or its sub-directories.

vak.files.from_dir`() is case-insensitive. For example, if you specify the extension as 'wav' then it will return files that end in '.wav' or '.WAV'. Similarly, if you specify 'TextGrid' as the extension, it will return files that end in .textgrid and .TextGrid.

If no files with the specified extension are found in the directory, then the function looks in all directories within dir_path and returns any files with the extension in those directories. The function does not look any deeper than one level below dir_path.

Parameters:
  • dir_path (str) – Path to target directory

  • ext (str) – File extension to search for. E.g., '.wav'.

Returns:

files – List of strings, paths to files with specified file extension.

Return type:

list

Notes

This function is used by vak.io.audio.files_from_dir() and vak.annotation.files_from_dir().