himanshud2611's picture
Upload folder using huggingface_hub
60e3a80 verified
raw
history blame contribute delete
622 Bytes
import os
def get_directory_size(directory: str) -> int:
"""
Calculate the total size of the directory by walking through each file.
Parameters:
directory (str): The path of the directory for which to calculate the size.
Returns:
total_size (int): The total size of the directory in bytes.
"""
total_size = 0
for dirpath, _, filenames in os.walk(directory):
for f in filenames:
fp = os.path.join(dirpath, f)
# skip if it is symbolic link
if not os.path.islink(fp):
total_size += os.path.getsize(fp)
return total_size