list_dir_names()

audeer.list_dir_names(path, *, basenames=False, recursive=False, hidden=True)[source]

List of folder names located inside provided path.

Parameters
  • path (Union[str, bytes]) – path to directory

  • basenames (bool) – if True return relative path in respect to path

  • recursive (bool) – if True includes subdirectories

  • hidden (bool) – if True includes directories starting with a dot (.)

Return type

List[str]

Returns

list of paths to directories

Raises

Examples

>>> _ = mkdir("path", "a", ".b", "c")
>>> list_dir_names(
...     "path",
...     basenames=True,
... )
['a']
>>> list_dir_names(
...     "path",
...     basenames=True,
...     recursive=True,
... )
['a', 'a/.b', 'a/.b/c']
>>> list_dir_names(
...     "path",
...     basenames=True,
...     recursive=True,
...     hidden=False,
... )
['a']