vocalpy.paths.from_dir

Contents

vocalpy.paths.from_dir#

vocalpy.paths.from_dir(dir: str | Path, ext: str, recurse: bool = False)[source]#

Get all paths with the specified extension from a directory.

Searches the directory with the pathlib.Path.glob() method. If recurse is True, a recursive glob is used (by prefixing the search string with double asterisks: sorted(dir.glob(f'**/*ext').

Parameters:
dirstr, pathlib.Path

The path to the directory.

extstr

The file extension to find, e.g. ‘wav’ or ‘.wav’.

recursebool

If True, search recursively in sub-directories of dir.

Returns:
pathslist

A list of pathlib.Path instances. Will be empty if no files with the extension were found.