code: def get_filebase(path, pattern):
      
      # A pattern can include directories
      tail_len = len(pattern.split(os.path.sep))
      return os.path.join(*str(path).split(os.path.sep)[-tail_len:])
docs: Get the end of *path* of same length as *pattern*.