makeroom.py

This is a script to ensure there’s a certain amount of free space on the disk. It works by deleting child directories until a target goal for free space has been reached. It is designed to run automatically on a machine that performs repetitive disk-clogging tasks, such as a nightly build machine.

You run it (for example) like this:

python makeroom.py -s 2.5*G c:\builds

It deletes child directories of c:\builds until there’s 2.5 Gig free on the disk. The child directories are deleted starting with the oldest by modification date. Directories that contain a file named “keep.txt” are never deleted. Deleting stops when the disk has enough free space. If the disk has enough free space to start with, nothing is deleted.

The -s argument is the amount of free space needed, and can be any Python numeric expression, with K, M, and G available for kilobytes, megabytes and gigabytes.

Download: makeroom.py

Comments

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.