0

How can I use python to monitor growth or capacity of a folder that is to determine the used and free space so that by the end of the day I can keep track how much my project is consuming space and create a graphical report for the same.

I tried to use os.statvfs function but it shows module 'os' has no attribute 'statvfs' I have got the idea to calculate used but if anyone can help with free space code would mean a lot. Thanks.

1 Answers1

0

You can do it like this:

import shutil

path = '/' # write any path here
total, used, free = shutil.disk_usage(path)

print("Total: %d GiB" % (total // (2**30)))
print("Used: %d GiB" % (used // (2**30)))
print("Free: %d GiB" % (free // (2**30)))
Geom
  • 1,491
  • 1
  • 10
  • 23