Python: script to clean windows disk after % usage
Question: I created a python script for cleaning old files on a windows disk. Now I want
to improve that script and check if I went over a predefined disk usage and
then delete files ... how I can do it? Here's my code:

    
    
    import os, time
    
    path = r"f:\backup"
    now = time.time()
    for f in os.listdir(path):
        if os.stat(f).st_mtime < now - 180 * 86400:
            if os.path.isfile(f):
                os.remove(os.path.join(path, f))
    

I need it because I've configured a backup of my computer on external disk and
sometimes it can't do the backup because disk is full.


Answer: I would recommend checking out this answer:

[Cross-platform space remaining on volume using
python](http://stackoverflow.com/questions/51658/cross-platform-space-
remaining-on-volume-using-python)

The nt implementation of the os module does not include the statvfs attribute,
so you'd need to recreate that functionality using c_types.

