Skip to content

Instantly share code, notes, and snippets.

@tankywoo
Last active October 14, 2015 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tankywoo/02688645c9aa31d1cc8f to your computer and use it in GitHub Desktop.
Save tankywoo/02688645c9aa31d1cc8f to your computer and use it in GitHub Desktop.
calculate directory size
# http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python
import os
def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
print get_size()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment