Created
April 14, 2020 15:58
-
-
Save 11philip22/1752c571fb94da8e554e320597e854d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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