SHARE
TWEET

Untitled

a guest Jan 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2.  
  3. def getFolderSize(folder):
  4.   total_size = os.path.getsize(folder)
  5.   for item in os.listdir(folder):
  6.     itempath = os.path.join(folder, item)
  7.     if os.path.isfile(itempath):
  8.       total_size += os.path.getsize(itempath)
  9.       if os.path.isdir(itempath):
  10.         total_size += getFolderSize(itempath)
  11.   return total_size
  12.  
  13. rootdir = "C:/temp/test/"
  14.  
  15. for root,dirs,files in os.walk(rootdir, topdown=True):
  16.     depth = root[len(rootdir) + len(os.path.sep):].count(os.path.sep)
  17.     if depth > 3:
  18.       dirs[:] = [] # Don't recurse any deeper
  19.       continue
  20.  
  21.     for dir in dirs:
  22.       if "archive" in dir:
  23.         path = os.path.join(root, dir)
  24.         size = getFolderSize(path)
  25.         print (path, size)
  26.         if size >= 1024: #bytes
  27.           print ("FOUND", path)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top