It's actually not really worth to put a post about this...but anyway :) I recently coded just a simple one-class prog
which deletes - or more specifically emtpies - a specified folder in certain time intervals.
You probably ask
yourself now what that should be good for. I'll try to explain it. It often happens to me that I create a text-file
just for the purpose of adding some note or for trying out some web-related code (as software developer) or I often
download files just to view them and so on. These files usually finish on my desktop or some other folder and most
often they are no more used and I forget to delete them. So I decided to code a little app (which is just 1 java-class
big or better small ;) ) which does the deletion for me.
The idea was to specify a certain folder in which I place
all my temporary stuff. The app should then check this folder periodically and delete its content every - say - 14 days
or so. One could now argue that this could also be done by writing a batch-file which deletes a certain folder and to
schedule the execution of this batch-file as a Windows "Scheduled Task". Yes it would, but not for all cases (or at
least I didn't found it out yet). Suppose for instance that I'm scheduling the job (deletion) to be done every Sunday
at 5.00 PM. If my machine is running at this time, everything works, if not, the job will not be repeated as soon as
I'm switching on my notebook on Monday morning. There may exist some free scheduling tools which may do this work
actually, however for myself it was easier to write this 50 line java app.
By the way...while writing this...it
came me in mind that I could change this small app in a way that it works as such a job scheduler by launching batch
files instead of doing the deletion (in this case) programmatically. This would render it more useful. Maybe I'll
change this.
In the mean time you can download the app "FolderCleaner" at
or
view the source in its SVN repository at
More
details about the usage can be found in the following
README
file which is also included in the ZIP download.
Questions? Thoughts? Hit me up
on Twitter