common_directory()

audeer.common_directory(dirs, *, sep='/')[source]

Find common directory path.

Parameters
  • dirs (Sequence[str]) – list of directories

  • sep (str) – path separator

Return type

str

Returns

part of the directory tree that is common to all the directories

Examples

>>> paths = [
...     "/home/user1/tmp/coverage/test",
...     "/home/user1/tmp/covert/operator",
...     "/home/user1/tmp/coven/members",
... ]
>>> common_directory(paths)
'/home/user1/tmp'