WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Environment Variable for Latest File Created
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1350550731

Message started by typecasket on Oct 18th, 2012 at 10:58am

Title: Environment Variable for Latest File Created
Post by typecasket on Oct 18th, 2012 at 10:58am
Hello Gert,

First of all, I would like to thank you for your superb article on QUIET by filter FILENEW (sending an email if no file is created within x seconds). I don't see that feature available to any monitoring tools online.
However I would like to include the "last file created" in my email alert. I can't see its corresponding env't variable in your list. Can you possibly create it if not yet available? Thank you in advance, more power and all the best!

Kudos Amigo!
8-)

Title: Re: Environment Variable for Latest File Created
Post by Gert on Oct 18th, 2012 at 11:43am
I guess you mean this blogpost: http://blog-en.gdpsoftware.com/2010/02/receive-email-when-no-files-are-created.html

Currently you can not get the latest file info, but here is a work-around.

Create a new task using the "run a batch file" plugin. It should use the same settings as your other task but without the QUIET event. The bat file should look like this (one line)

@ECHO %WD_REASON% %WD_DTTM% %WD_FILE% > "C:\Temp\TheLastEvent.txt"

So this will write a line with the reason (FILENEW/FILECHNG...), timestamp and filename to "C:\Temp\TheLastEvent.txt", overwriting its old contents every time.

Now you can include this file in your email message for the QUIET event (in your original task), so the message body will be something like this:


Hello,
Nothing happened in the monitored directory for some time. The last event was:
@@@C:\Temp\TheLastEvent.txt@@@


Not tested but it should work.

Gert

Title: Re: Environment Variable for Latest File Created
Post by typecasket on Oct 19th, 2012 at 5:37am
Hello Gert,

I created the "Run any bat file" first and followed your instructions but it did not write the output to LastEvent.txt after starting the task. Also how can I attach the file in my QUIET email message? I am seeing checkbox for "Attach the file (new and changed files only)" below the email message body.
Thanks for your quick response!

Kudos Amigo,
8-)

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.