Skip to content

Instantly share code, notes, and snippets.

@11philip22
Created April 14, 2020 15:58
Show Gist options
  • Save 11philip22/1752c571fb94da8e554e320597e854d3 to your computer and use it in GitHub Desktop.
Save 11philip22/1752c571fb94da8e554e320597e854d3 to your computer and use it in GitHub Desktop.
from os import walk, path
def get_folder_size(start_path):
""""Output size of folder in bytes"""
total_size = 0
for dir_path, dir_names, file_names in walk(start_path):
for f in file_names:
fp = path.join(dir_path, f)
# skip if it is symbolic link
if not path.islink(fp):
total_size += path.getsize(fp)
return total_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment