diff --git a/fsl/utils/path.py b/fsl/utils/path.py index e9a577f20e69d69e3641c12f0674962ad3bd3c87..e45f82213f0b44495bd1c6e4573bb5ab169b7c1d 100644 --- a/fsl/utils/path.py +++ b/fsl/utils/path.py @@ -485,14 +485,17 @@ def commonBase(paths): depths = [len(p.split(op.sep)) for p in paths] base = max(zip(depths, paths), key=operator.itemgetter(0))[1] + last = base while True: base = op.split(base)[0] - if len(base) == 0: + if base == last or len(base) == 0: break + last = base + if all([p.startswith(base) for p in paths]): return base