Skip to content

Instantly share code, notes, and snippets.

@kawakami-o3
Created May 18, 2021 03:55
Show Gist options
  • Save kawakami-o3/2ae7f99cccbfa322c2cf6aa301d93c10 to your computer and use it in GitHub Desktop.
Save kawakami-o3/2ae7f99cccbfa322c2cf6aa301d93c10 to your computer and use it in GitHub Desktop.
import os
def get_size_dir(path='.'):
total_size = 0
for dir_path in os.listdir(path):
full_path = os.path.join(path, dir_path)
if os.path.isfile(full_path):
total_size += os.path.getsize(full_path)
elif os.path.isdir(full_path):
total_size += get_size_dir(full_path)
return total_size
print(get_size_dir('.'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment