code: def walk_dir_progress(path, maxdircnt=5000, file=sys.stdout):
      
      p = ProgressBar(
          'Walking {}'.format(C(path, 'cyan')),
          bars=Bars.numbers_blue.with_wrapper(('(', ')')),
          show_time=True,
          file=file,
      )
      rootcnt = 0
      print('\nStarting progress bar...')
      p.start()
  
      for root, dirs, files in os.walk(path):
          rootcnt += 1
          if rootcnt % 100 == 0:
              p.update(
                  percent=min((rootcnt / maxdircnt) * 100, 100),
                  text='Walking {}...'.format(
                      C(os.path.split(root)[-1], 'cyan'),
                  )
              )
  
          if rootcnt > maxdircnt:
              # Stop is called because we are printing before the
              # AnimatedProgress is finished running.
              p.stop()
              print(
                  '\nFinished walking {} directories.'.format(
                      C(maxdircnt, 'blue', style='bright')
                  ),
                  file=file,
              )
              break
      else:
          # AnimatedProgress still running, `stop` it before printing.
          p.stop()
          print_err(
              '\nNever made it to {} directories ({}).'.format(
                  C(maxdircnt, 'blue', style='bright'),
                  C(rootcnt, 'red', style='bright'),
              )
          )
      print('\nFinished with progress bar.')
      return 0
docs: Walk a directory, printing status updates along the way.