TheProfosist

Directory Listing with size (no sub folders) via Python 03

Jul 1st, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. def get_size(start_path = '.'):
  3.     total_size = 0
  4.     for dirpath, dirnames, filenames in os.walk(start_path):
  5.         for f in filenames:
  6.             fp = os.path.join(dirpath, f)
  7.             total_size += os.path.getsize(fp)
  8.     return total_size
  9.  
  10. print(get_size()/1024/1024/1024)
Add Comment
Please, Sign In to add comment