This is a little program I made some time ago because I had some problems with some log files I generated. I didn’t know how big they would end up and I had a limited disk space. As you can guess, it can be used for any files. So I could have called it “DOF * Delete Oldest Files”.

The idea of this tiny .Net program is to delete the oldest logs first. It scans every files and delete as many files as required to reach its objectives.

Command line arguments (-h option):

Arguments are :
===============
-d          : Directory where to analyse files
-dr         : Directory where to analyse files recursively
-de         : Delete empty dirs
-sm         : Sort files by modification (default)
-sc         : Sort files by creation
-sa         : Sort files by access
-ds <size>  : Delete oldest logs to reach a total size of <size> (in bytes)
-dn <nb>    : Delete oldest logs to reach a total number of <nb>
-v          : Switch to verbose mode
 
Numbers can have k,m,g :
1k = 1 024         bytes
1m = 1 048 576     bytes
1g = 1 073 741 824 bytes

So, on Windows, you will probably do somethind like :

dol.exe -de -dr C:\temp -ds 2g</pre>

On Linux, it’s the same thing with a “mono” before.

mono dol.exe -dr /var/log/apache -ds 1g

You can download it here (13.5 KB).