Standard edition $69 (US Dollar)
Professional edition $129 (US Dollar)
Volume discounts available
Or download the 30 day evaluation version of watchDirectory (~4 MB)
platforms Windows® 2000/XP/2003/Vista/2008
WatchDirectory Newsletter - Detecting an outbreak of new files
At most once a month we send a newsletter to keep you informed about watchDirectory.
You can unsubscribe anytime you want.
We care about your privacy and will not make your email available to other parties.
| Subscribe to the English language newsletter |
Den Deutschen Newsletter abonnieren |
|
|---|
|
Recently a customer asked whether watchDirectory can take action when more than 30 files were created during the last 10 minutes. When less files were created, nothing should happen. When more files were created, watchDirectory should send an e-mail alert. For this example, you should configure a new task that runs a batch file for all new files detected in the watched directory. The batch file will read the history database (the same as used by the Task History Viewer) to check how many files were created the last 10 minutes. When more than 30 files were created, the batch file will send an e-mail. The outbreak.bat scriptThe example script uses a program called sqlite3.exe, which is part of the excellent SQLite database engine
used by watchDirectory. The sqlite3 program is included in the download at the bottom of this page. rem path to sqlite3.exe (no "quotes") SET SQL=C:\outbreak\sqlite3.exe rem time interval to use in minutes SET MINUTES=10 rem the number of files allowed before triggering an email SET MAXFILE=30 rem who should receive the email alert? SET EMAIL=johnny@somewhere.net rem =============================================== rem ==== no need to change anything below here ==== rem =============================================== rem create temporary files inside C:\Documents and Settings\All Users\Application Data\watchDirectory\taskname\... SET TFBASE=%WD_TASKDIR%\F1%WD_CUREVT% rem compute the date/time of MINUTES minutes ago "%WD_INSTDIR%\GdPUtil.exe" -datetime -%MINUTES%m "%TFBASE%.bat" call "%TFBASE%.bat" del "%TFBASE%.bat" rem create the query SET TMST='%DT_YEAR%-%DT_MONTH%-%DT_DAY% %DT_HOUR%:%DT_MIN%:%DT_SEC%' rem always take care with pipe and "greater than" characters (escape them) ECHO Select 'set numfiles=' ^|^| count(*) from WDEVENTS where DTEVENT ^> %TMST%; > "%TFBASE%.SQL" rem and start the query type "%TFBASE%.SQL" | "%SQL%" "%WD_TASKDIR%\history.db" > "%TFBASE%NF.BAT" del "%TFBASE%.SQL" call "%TFBASE%NF.BAT" del "%TFBASE%NF.BAT" if %numfiles% LSS %MAXFILE% ( rem less than MAXFILE files were created the last MINUTES minutes goto :EOF ) rem more than MAXFILE files! send an email alert set EMAILFILE=%WD_TASKDIR%\..\System.Mail\Out\%WD_CONFIG%_%WD_CUREVT%.TMP echo ALERT: %numfiles% files created in directory %WD_DIR% > "%EMAILFILE%" echo %EMAIL% >> "%EMAILFILE%" echo. >> "%EMAILFILE%" echo. >> "%EMAILFILE%" echo. >> "%EMAILFILE%" echo. >> "%EMAILFILE%" echo Hi, >> "%EMAILFILE%" echo During the last %MINUTES% minutes there were %numfiles% files created inside directory %WD_DIR% >> "%EMAILFILE%" rem okay, the script is created, now rename it so the wdPostMan program processes it. ren "%EMAILFILE%" %WD_CONFIG%_%WD_CUREVT%.wdmail Download the outbreak example. Unzip all files into a new directory. C:\outbreak would be easiest as the example script is configured to use that directory. |
Standard edition $69 (US Dollar)
Professional edition $129 (US Dollar)
Volume discounts available
Or download the 30 day evaluation version of watchDirectory (~4 MB)
platforms Windows® 2000/XP/2003/Vista/2008
Customer testimonial
...I use WatchDirectory for monitoring each yachts inbox, and when a new file arrives it moves the files to an approval queue.
Once the material has been approved, it is moved to another directory....
(Volvo Ocean Race)Complete testimonial
Monitor the size of your folders
Automatically delete (or move) files from the monitored directory when it is filling up. Allow a maximum of X files or megabytes, and watchDirectory will (re)move the oldest.
More ![]()
Send email for old files!
Receive email notifications for old files - great for workflow (e.g. warn John that he didn't process the file, and CC yourself and his colleagues...).
More ![]()
Automate all your file processing!
Need even more flexibility? Automatically start your batch scripts when files in a watched directory are created or changed.
More ![]()
Find out WHO is deleting files from your server!
watchDirectory can send you an auditing report showing you who, what, when and where.
It is up to you to discover why...
More ![]()