old_contents: #!/usr/bin/env python
  import sys
  import os
  
  '''
  List files and subdirectories of a given path in a tree structure
  '''
  
  def main(startpath):
      for root, dirs, files in os.walk(startpath):
          level = root.replace(startpath, '').count(os.sep)
          indent = ' ' * 4 * (level)
          print('{}{}/'.format(indent, os.path.basename(root)))
          subindent = ' ' * 4 * (level + 1)
          for f in files:
              print('{}{}'.format(subindent, f))
  
  if __name__ == '__main__':
      main(sys.argv[1])
  
new_contents: #!/usr/bin/env python
  import sys
  import os
  
  def main(startpath):
      for root, dirs, files in os.walk(startpath):
          if "." in root:
              pass
          else:
              print root
              level = root.replace(startpath, '').count(os.sep)
              indent = ' ' * 4 * (level)
              print('{}{}/'.format(indent, os.path.basename(root)))
              subindent = ' ' * 4 * (level + 1)
              for f in files:
                  print('{}{}'.format(subindent, f))
  
  if __name__ == '__main__':
      main(sys.argv[1])
  
subject: Update listtree.py