WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Filter by file size? (Read 118 times)
Rawson819
YaBB Newbies
*
Offline



Posts: 5
Filter by file size?
Sep 6th, 2017 at 1:44pm
 
Is there a way in WD that I can filter by file size?  I have a daily report that I've been emailing to staff using WD.  It worked perfectly until the originating software started creating the report in triplicate, with two of the files being nearly blank, except column headers.

Until the triple report problem can be solved, I was wondering if I could have WD ignore files that are 6KB or less. I would also add that there is never any consistency to the order in which the three files appear.  On days when the first file is the one with data, things are great; however, when not, a blank report goes out.  I'm open to any suggestions, if there is perhaps another way around the issue.  Thanks,
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2233
The Netherlands
Re: Filter by file size?
Reply #1 - Sep 7th, 2017 at 6:33am
 
Hi,

Make sure you run the latest version of WatchDirectory. Change the task settings as follows:
Change the "Monitoring Method" to either "Polling" or (better) "File Age" and set the "age" to 1 minute, also let it "remember triggered files".
At the bottom of "Filter Events" add a filter script, for example C:\Scripts\filter6kb.bat. This script should look like this:
Code:
rem ignore all files smaller than 6kb

rem file does not exist... we are probably called by the Control Center to test
rem just tell WD to ignore this event.
IF NOT EXIST "%WD_FILE%" GOTO :SayNo

IF %WD_FILE_SIZE_KB% LEQ 6 GOTO :SayNo

rem file is bigger than 6kb
GOTO :SayYes

:SayYes
ECHO Y > "%WD_FILTERRESULT%"
GOTO :EOF

:SayNo
ECHO N > "%WD_FILTERRESULT%"
GOTO :EOF
 





The reason why you can not use the "Default" or "Fast" monitoring method is that those methods may detect the file to quickly. All files always start their life as zero-byte files (even if just for a few milliseconds) so "Fast" could call your filter script too soon.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Page Index Toggle Pages: 1