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
Folder Monitoring - If any file exists, then email (Read 7094 times)
mborrego
YaBB Newbies
*
Offline



Posts: 3
Folder Monitoring - If any file exists, then email
Mar 6th, 2013 at 1:06am
 
We are looking to puchase multiple copies of this software at our company to monitor folders as part of our accounts receivable workflow.  So far, the software looks very powerful!

Is there a way to monitor a directory, twice a day, and, if there are any files within that directory, no matter how new or old, send an email notification, preferably at specific times (say 8 AM and 5 PM)?

I have set up two tasks to try and acheive this, but have failed each time.  Am I missing something?

I set up a "Send Email" task, but this sends an email per file added to the directory.  So, if 50 files are added to the directory, 50 emails will be sent.

I set up a "Monitor Folder Size" task, but this will send an email once when there is a file in a directory, but not again unless a new file is added or removed from the directory.

Any help is appreciated!
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2239
The Netherlands
Re: Folder Monitoring - If any file exists, then e
Reply #1 - Mar 6th, 2013 at 8:49am
 
Hi. Yes, that's just the way WatchDirectory works, tasks run for each detected file.

Here is something you can do by creating 2 tasks.
Task-1 uses the "Run a batch script" plugin ( http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBat.html )
and monitors your directory. Make sure to set the option "fire filenew for all files at startup" ( http://www.watchdirectory.net/wdhelp/help/wdnewconfigpage6.html ).
Let it use the "polling" monitoring method with a very high polling interval (a few hours).
Let this task run the following bat file for detected files:
Code:
echo detected some file >> "C:\DirForTask2\%WD_CURRUN%.txt"
 


WD_CURRUN is set to the current run-number of the task so it will be the same each time the script is called.
The script creates/moddifies this file in quick succession.

Task-2 monitors directory "C:\DirForTask2" (the directory where task-1 creates the new file) for new files and sends your email.

Now use the Windows scheduler to automatically start Task-1 at 8 AM and 5 PM, using the Windows scheduler again
to STOP task-1 at 8:05 AM and 5:05 PM. This is explained in this blogpost: http://blog-en.gdpsoftware.com/2008/09/automatically-start-watchdirectory.html

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
 
mborrego
YaBB Newbies
*
Offline



Posts: 3
Re: Folder Monitoring - If any file exists, then e
Reply #2 - Mar 7th, 2013 at 2:42am
 
This works great!  Thank you for the steps on how to get this done.

The only minor issue I had, is that every time the task is stopped, and restarted, a new .txt file with a new task ID is generated.

I just used a static name for the .txt file, and it fixed the issue.

Thanks again!
Back to top
 
 
IP Logged
 
mborrego
YaBB Newbies
*
Offline



Posts: 3
Re: Folder Monitoring - If any file exists, then e
Reply #3 - Mar 12th, 2013 at 8:55pm
 
Actually, we are having problems with these tasks.  I thought they were working correctly, but it appears emails are being triggered every time the jobs run.  I'm not sure what I'm doing wrong.

My goal is to have watchDirectory Pro check for the existence of ANY files , old or new, in the monitored directory.  If it detects any files (not folders), it will email someone.

As you suggested, I have done the following:
1.  Created a 1st task that monitors a network location for FILENEW events.  If a FILENEW event is triggered, then it will run the batch file to append lto a file called "monitor.txt".
2.  Created a 2nd task that monitors the "monitor.txt" file for changes, and if there are changes, it triggers an email to be sent to the user, letting them know there are files in their folder to review.

The problem with this, is that task 1 is ALWAYS appending data to monitor.txt, even when the directory is empty, even when no new files are created.  It appears that FILENEW is only modifying the MODIFY date on the file, not the CREATION date?  Is that correct?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2239
The Netherlands
Re: Folder Monitoring - If any file exists, then e
Reply #4 - Mar 13th, 2013 at 10:44am
 
afterthought... task 2 (the email task) should NOT have the option "fire filenew for all files at startup" enabled. If you enabled that for task-2, that would explain this issue.....



I am not sure what is happening. Please help to "debug" this.

Change your .bat file like this:
Code:
ECHO %WD_FILE% >> "C:\SomeDir\monitor.txt"
 


This will append the detected file name to your monitor.txt file.

For your 2nd task (that emails), let it attach the detected file and remove it after sending the message.

That way the attachment will show you for what files WD task 1 was triggered.
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