Standard edition $79 (US Dollar)
Professional edition $149 (US Dollar)
Volume discounts available
Or download the 30 day evaluation version of watchDirectory (~8 MB)
platforms Windows® 2000/XP/2003/Vista/2008/7
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 $79 (US Dollar)
Professional edition $149 (US Dollar)
Volume discounts available
Or download the 30 day evaluation version of watchDirectory (~8 MB)
platforms Windows® 2000/XP/2003/Vista/2008/7
Customer testimonial
Watchdirectory has saved dictationstore.com, Inc. thousands of dollars in development costs.
We needed a way to provide multiple automated back-end processes for each one of our customers. When we looked at the costs to code these processes into our applications it was outrageous - and what if the customer needed something changed?Complete testimonial
Play a sound file when new files are created
Automatically play a WAV file when new files are created.
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 ![]()
Copy or Move your New and Changed files!
watchDirectory can distribute your files to multiple destination folders. Enjoy 100% flexibility by using Dynamic Naming for your target files!
More ![]()
Automatically create Thumbnails for your Pictures
Create JPG, GIF or PNG thumbnails for new JPG, BMP, GIF, PNG, TIFF, PCX, TGA, WMF, EMF, PCD, and PSD files. Pictures can be automatically rotated as well!
More ![]()