msgbartop
Code Musings and Such
msgbarbottom

31 Dec 09 ColdFusion FileSweeper

I'm tired writing scripts to clean up temporary files.

It's a nigh trivial task. The chance for error is small, but the consequences can be dire!

DIRE!

DIRE!

I wrote a little utility that makes this a little easier. It simply deletes all the files in a folder (recursive or no) that are older than a specified number of seconds.

Example Usage:

// no init needed, but the function's there if you like
fileSweeper = CreateObject("component", "fileSweeper");   

// all arguments are actually defaulted to the values shown
// so you needn't pass any, fancy eh?
fileSweeper.deleteOldFiles(
    folder   = ExpandPath("/temp"),
    seconds  = 600,
    filter   = "*.*",
    recurse = "no",
    lockname = "deleteFiles",
    timeout  = 60,
    logging  = true
);

Download it!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Tags: ,

Leave a Comment