pyufunc.get_filenames_by_ext#

pyufunc.get_filenames_by_ext(dir_path, file_ext='csv', incl_subdir=False)#

Get a list of filenames in a folder by file extension.

Location:

pyufunc/util_pathio/_path.py

References

mikeqfu/pyhelpers (GNU)

See also

get_files_by_ext

Parameters:
  • dir_path (str | Path) – the path to the folder

  • file_ext (str | list | tuple, optional) – the file extension to be specified. Defaults to “csv”.

  • incl_subdir (bool, optional) – Whether to traverse all files inside sub folder. Defaults to False.

Returns:

a list of filenames with absolute paths

Return type:

list[str]

Examples

>>> import pyufunc as uf
>>> uf.get_filenames_by_ext('./', 'py')
['C:/Users/Administrator/Desktop/test/test.py']