Thursday, December 31, 2009

BullDoze - File Cleanup Utility

Download: File-delete utility for deleting old log files. The "BullDoze" utility can automatically delete, move or rename files older than xx days. You are welcome to download and use this program free of charge.

Corporate servers often have processes that generate temporary files and those files sometimes need periodic deleting. Classic examples include
  • Fax Server sent-fax folders
  • Medical Image Gateways and other image processing servers
  • Sharepoint Log files in the bin\12\logs folder
  • Temp directories, etc.
The issue is this: Deleting files is easy. It is harder to delete files older than (30) days and logging what was deleted is even more troublesome. I wrote a simple program to do all of this and it is intended to run unattended.

You are free to download and use this program with no strings attached (see instructions, below).

BullDoze Features

BullDoze.exe is a .net 2008 compiled program that has the following features:
  • It can Delete, Rename, Move, or MoveRename files
  • Triggers on a file-age; all files older than xx-days
  • Optionally, all files can be deleted
  • Can identify and delete millions of files
  • Optionally, aged files can be moved to a different (backup) directory
  • No installation required; No registry entries
  • Command-line-driven
  • Auto-starts, runs, then auto-closes
  • The process can be run any number of times, against multiple directories
  • Full Logging is supported. Each process can log independently or all logs can be combined.
  • Scheduleable with Windows Scheduler or other
  • Can easily be batched

1. Download exe from Keyliner's public GDrive: BullDoze on Keyliner GDrive.
You do not need to register when downloading.
2. Place exe on any Windows server or workstation, in any directory.
3. Launch the program passing command-line parameters. Typically launched in a scheduler of some type

Notes: DotNet 2.0 must be installed.
Generally, BullDozer.exe is copied to a UTIL directory or it can be placed directly in the (Log or Temp directory you wish to cleanup (it never deletes itself or its control or log files).

Command Line Parameters:

BullDoze is a command-line-driven application and for safety, once launched, you cannot enter or change parameters on the screen. Optional parameters are in italics:

Days=nn | Days=-1 to delete all files unconditionally
LogResults=y/N | LogResults="C:\path\filename.log"
DestinationDir="directory\path" (if using MOVES)
Overwrite=y/N (Allow overwrites on Moves/Renames)

BullDoze.exe Action=Delete SourceDir="C:\Temp" Files="*.*" Days=90 LogResults=Y

where all files older than 90 days, any extension, will be deleted from C:\Temp. Results are recorded in the current directory in file "BullDoze.log". This is typed as a one-line command and can be placed in a batch file or in Windows Scheduler.

  • All parameters are keyword=value pairs. e.g. Action=DELETE
  • Parameters are not case-sensitive
  • Embedded spaces are not allowed unless enclosed in quotes. e.g. SourceDir="C:\Test folder\directory"
  • Do not use spaces as in (Action = Delete)
  • Source and Dest directories can be \\server\path names
  • Client must be pre-authenticated to remote servers
  • Bulldoze runs as the current user; use Windows Scheduler to run with different credentials

Typical Use:
From a server, open the Control Panel, Scheduler, and add a new task, calling BullDoze.exe. While building the schedule, click Advanced properties, and add the parameters. Let Windows Scheduler run the program once per day. Details on this will be added to this article in the future.

Parameter Details:

In-use, write-protected, insufficient-rights, files are not deleted. Failures are recorded in the (optional) LOG file and will not cause the program to fail.

Requires a DestinationDir.
If the file already exists in Destination, it will not overwrite unless "OverWrite=Y" is explicitly stated.

Renames the file, leaving it in the current directory.
Renames are OriginalFileName_yyyymmdd_hhMMss.ext
If file has already been renamed within the same day, it will not attempt a second rename unless OverWrite=Y.
Rename with date-time stamp is the only option supported at this time.
Failed Renames are logged.

Moves the file to the DestinationDir and renames, following the same rules, described above.

Path must pre-exist
Path can be in the form "C:\path\path" or "\\server\share\path"
Quotes should be used on all paths; required if embedded spaces
If server path, client must be pre-authenticated prior to running BullDoze. This will be a future enhancement.
Do not use file-masks in the SourceDir (see Files=)
Generally, the SourceDir is on the same machine as the program.

Standard DOS file masks are supported.
Examples: *.* All files eligible
*.LOG only (delete) Log files
2009_*.LOG, etc.

Required if MOVE or MoveRename

Specifies the age the file must be, in days, before the action is taken.
e.g. Days=30
Use Days=-1 (no spaces) to delete all files, regardless of age.
Days=0 is illegal.

If not specified, results are not Logged.
If LogResults=Y, a default log file (BullDoze.Log) is created in the current DOS directory.
If LogResults="C:\Filename.exe", "Y" is assumed and this log-name is used.
Log files can be stored in the SourceDirectory and are not deleted.
Log Files are a standard ASCII text file, viewable with Notepad.
Subsequent runs overwrite the log file, replacing the older copy, unless AppendLog=Y.

If AppendLog=Y, log entries append, newest last. Caution, log files can get large. This utility will not manage its size and it can grow very large. Use with caution.

During a Move or Rename, if the destination file already exists, it will be overwritten if this switch is set to Y. Otherwise, the file fails and is logged. Generally, all MOVES and RENAMES should allow overwrites.

I just used this program to delete 1.8M files (yes, that is in Millions) from a Rightfax server.  It worked swell, although I could see a minor problem in the display, where it did not report "deleting" until several minutes into the process.  This is a cosmetic issue.

Licensing and Restrictions on use:
For personal, commercial and governmental use. You may distribute with other software, provided credit is given to the author and a reference to this article. If you make a lot of money with the help of this program, consider me and my family. I am open to custom enhancements.

Future enhancements
If there is enough demand, I am contemplating these enhancements:
  • Support for INI file parameters
  • Support for multiple actions within one INI
  • Support for File Inclusion/Exclusion lists
  • Logic to map and authenticate to drives
  • LogFile truncation after xx-bytes
  • Self-scheduling
Suggestions are welcome. I'd like to know if you use the program, drop me a note here on this blog.

automatically delete old files
cleanup old files
bulldozer file-delete

No comments:

Post a Comment

Comments are moderated and published upon review.