I'm not a qualified programmer, but I've written a small Windows Scripting Host script that:

   1. tallies the COUNT or SIZE of files that match a regular expression
   2. compares either the count or size to a threshold
   3. returns an errorlevel based on the result of the comparison

Instead of keeping it to myself, I thought it would be nice to offer it to others who could possibly use it too. If you're interested, you can email me off-list and I'll send it to you. Below is the output from the script's help text (view as fixed-width text for best results).

Nate Morris
[EMAIL PROTECTED]

<script_output>

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.


Author: Nate Morris ([EMAIL PROTECTED]) Version: 0.1 Date: 2003/12/12

Usage: fsummary.wsf /location:"<string>" [/pattern:"<string>"] [/count|/size]
                        /threshold:"<size or count>" [/recurse] [/debug]

Command-line arguments:
------------------------------------------------------------------------------
location:       Path of the folder you wish to inspect.
pattern:        Regular expression pattern. The pattern is compared to
                file names in location to determine whether to add file
                information to the summary data. Default = ".*" (all files).
threshold:      Size (in b, kb, mb, or gb) or count. Must correspond to /size
                (e.g. "100 mb", "6kb", "1 GB", "50 b", etc.) or /count arg.
                If size is specified and no b, kb, mb, or gb is added, the
                value is assumed to be in bytes. You MUST use double-quotes
                around the value you specify for threshold, even if it is a
                straight integer value.
count:          Compare threshold to the count of matching files.
size:           Compare threshold to the total size of matching files.
recurse:        Perform the summary operation recursively.
debug:          Display extra output.

Examples:
  *     Find all files in a folder and its subfolders with the word "log"
        in the filename and return errorlevel 2 if their total size is
        larger than 500 mb.
        
        fsummary.wsf /location:\\server1\share /pattern:".*log.*"
                        /threshold:"500 mb" /size /recurse

  *     Find all files in a folder with filenames of the format
        ####-XXXXXX.4C03, where # is a numerical digit and X is a letter.
        Return errorlevel 2 if there are more than 100 matching files.

        fsummary.wsf /location:\\server1\share /threshold:100 /count
                        /pattern:"^\d{4}-[a-zA-Z]{6}.4C03$"

Return Values (Errorlevels):
------------------------------------------------------------------------------
0       The number or size of matching files was at or below the threshold.
1       An unknown error was encountered in the script.
2       The number or size of matching files was over the threshold.
4       Invalid version of Windows Scripting Host. (Minimum = v5.6)
5       Location switch required.
6       The location you specified was invalid or inaccessible
7       You may not specify both /count and /size arguments
8       Threshold switch required.
9       The threshold argument was improperly formatted.

</script_output>

To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
  unsubscribe SAlive

Reply via email to