In the place where I work, we have numerous SendPorts that we sometimes enable that create copies of BizTalk messages on the disk, in a directory called D:\MessageLog (with various sub-directories).

Rarely do we need to go back more than 2 or 3 days to see these files.

We have a Powershell script in place to help clean-up these files. We are a very high volume system, and we can end up with tens or hundreds of thousands of these messages in a few days.

#All files older than x days in D:\MessageLog
# $_.PsIsContainer tells you that you have a folder
GET-CHILDITEM D:\MessageLog -RECURSE| Where { $_.LastWriteTime.AddDays(2) -lt (GET-DATE) -and -not $_.psiscontainer} |% {REMOVE-ITEM $_.fullname -force}

This script could be scheduled by Windows Task Manager. To make things easier, I usually create a one line .bat or .cmd file like the one below. The scheduler simple executes the .cmd file.

powershell -command "& 'CleanupMessageLog.ps1'"

or if the Ampersand gives you errors, try

powershell -command ". 'e:\Projects\MyApp\CleanupMessageLog.ps1'"

NOTE: Put the folder name in double quotes if it contains any embedded spaces.

Compare to VBScript cleanup/delete files script.