WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Wish: Trigger for first file only within x seconds
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1284042780

Message started by Dschuwi on Sep 9th, 2010 at 4:33pm

Title: Wish: Trigger for first file only within x seconds
Post by Dschuwi on Sep 9th, 2010 at 4:33pm
I have set email alert if new files arrive in a directory.

I would like to get a mail once only, then have the task suspended for a certain amount of time, so I don't get flooded with mails of every single file.
This wish is actually not restricted to the email plugin, it could be an interesting general event option.

And if you tell me now, this is possible already, I could not find out how to do this, but I would not be surprised... :-)

Title: Re: Wish: Trigger for first file only within x sec
Post by Gert on Sep 9th, 2010 at 5:14pm
Interesting idea....

For the Email task, something like this is possible by using the Combine option, see the bottom of this page:
http://www.watchdirectory.net/wdhelp/plugins/wdopAutoEmail.html

When you use the "Combine" option, you receive 1 email with several notifications combined.

Title: Re: Wish: Trigger for first file only within x sec
Post by Dschuwi on Sep 13th, 2010 at 9:54am

Gert wrote on Sep 9th, 2010 at 5:14pm:
When you use the "Combine" option, you receive 1 email with several notifications combined.


Works basically, but I donot get a "combined" mail - I receive a mail after the specified amount of time, but with the text of the first new file only.
(in that case it would be definitely better to get it immediately after the first file, and then wait for e.g. ten minutes).

hp

Title: Re: Wish: Trigger for first file only within x sec
Post by Gert on Sep 13th, 2010 at 11:24am
While there should be multiple combined notifications? Are you saying you do not receive some notifications when you combine them?

Can you email me your task settings as described in this blogpost:
http://watchdirftp.blogspot.com/2010/06/send-task-backup-to-support.html

Title: Re: Wish: Trigger for first file only within x sec
Post by YorkieBar on Oct 13th, 2010 at 1:45pm
We have a need to EITHER trigger a task only once every x seconds OR identify a file isn't present in a directory.

We FTP download a series of files and need to read and process each file separately using an Excel Program called by a Start Any Program task.
The processing time for each file can vary depending on the file size but is typically 15-90 seconds.
I want to be able to
 Drop the FTP file into a directory with a static name (e.g. input.txt)
 Run the Start Any Program Excel Macro - after various calculations this task renames input.txt to outputYYMMSSHHMMSS.txt
 After x seconds copy the next FTP file into the directory again called input.txt
 Run the Start Any Program task etc

Alternatively - Is there a way to copy the next FTP file into the directory only when input.txt does not already exist.

Title: Re: Wish: Trigger for first file only within x sec
Post by Gert on Oct 14th, 2010 at 5:17am

Quote:
Alternatively - Is there a way to copy the next FTP file into the directory only when input.txt does not already exist.


I think this might work:
Use the "Copy" task and make sure to let it NOT copy if the file exists
This task should use the "File Age" monitoring method:
- Files older than 1 minute
- Do NOT remember triggered files
This last setting (NOT remember....) will cause the task to "fire" for all existing files again and again. If you do select the option to remember triggered files, it will only try to copy files once.


Title: Re: Wish: Trigger for first file only within x sec
Post by YorkieBar on Oct 14th, 2010 at 12:29pm
I am trying this out but am unclear how the files will move singularly.
The FTP transfer drops a number of files (5+) into a FTPTemp directory with names File001.csv, File002.csv etc.
The Excel program needs to work with a static file name in a set directory e.g. DirExcel

I therefore need to copy File001.csv from directory FTPTemp to DirExcel and rename it from File001.csv to input.txt.
When file input.txt exists in DirExcel the Excel program task starts, processes and renames input.txt
Until input.txt has been processed I don't want File002.csv to be copied/renamed.
The Copy Task has the option to NOT copy if the file exists but doesn't allow a rename at the same time i.e. it picks up File001.csv and moves it as File001.csv not input.txt.
What step am I missing?  :-?

Title: Re: Wish: Trigger for first file only within x sec
Post by Gert on Oct 14th, 2010 at 12:46pm
I forgot about that rename requirement.
Instead of the "Copy Files" task, use the "Run a batch file" task and let it start this script:
[code]rem where should the detected file be moved to?
SET TARGETFILE=input.txt
SET TARGETDIR=C:\DirExcel
rem if the target file exists, how long to wait before trying again?
SET SLEEP=5

:SleepLoop
IF NOT EXIST "%TARGETDIR%\%TARGETFILE%" GOTO :ContinueMove
"%WD_INSTDIR%\GdPUtil.exe" -sleep %SLEEP%
GOTO :SleepLoop


:ContinueMove
MOVE "%WD_FILE%" "%TARGETDIR%\%TARGETFILE%"

[/code]

I think that should work fine.

Title: Re: Wish: Trigger for first file only within x sec
Post by YorkieBar on Oct 14th, 2010 at 3:11pm
Thanks Gert - it's just what we needed. :)
This is a great way to create a sequential process queue.

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