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
Problem with FILEREN event (Read 4476 times)
stramels
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Problem with FILEREN event
Jan 21st, 2005 at 10:56pm
 
We are trying to use watchdirectory to execute a batch encoder on files that are uploaded into our web server.  When the process starts uploading the file and we have the Configuration Utility use the FILENEW event, the batch program kicks off prior to the file being completely uploaded.  We cannot use the DELAY Start feature because we do not know if the file that is being uploaded is a 500k file or a 5MB file and how long it will take over the end users data line.

We have tried to use the Configuration Utility to set the Monitoring Method to FAST so we can use the FILEREN event but when we try to execute it by pressing the green start button, it gives us an error saying "No events selected".  We have double checked to insure that the FILEREN event is checked but it still doesn't work.  What am we missing?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Problem with FILEREN event
Reply #1 - Jan 22nd, 2005 at 2:22am
 
Hi,

Quote:
We have double checked to insure that the FILEREN event is checked but it still doesn't work


Sorry for the confusion, but FILEREN needs another 'filebased' event selected to operate properly. For example FILENEW.

If you are not interested in FILENEW events, you can easily ignore them inside the .bat file:
Code:
IF "%WD_REASON%" == "FILENEW" GOTO :EOF
 



However, I don't think using FILEREN would help. Your encoder probably doesn't rename the file, but delete the original and create a new one. Maybe I misunderstand.

Quote:
the batch program kicks off prior to the file being completely uploaded

Depending on the program uploading the file, this can sometimes happen. Most programs that create files will 'lock' the file during creation, and only 'unlock' it when it is complete. Some programs create the first part of the file, unlock, lock, second part, unlock, lock, third part and so forth.
When the file is unlocked watchDirectory will fire the event. Also, you will need to uncheck the option "don't wait for files to be available" so watchDirectory waits until the file is unlocked.

The solution for this situation, is to use a small commandline utility, WaitFileComplete:
http://www.watchdirectory.net/downloads/WaitFileComplete.zip

This program will 'monitor' a file and wait until its size doesn't change anymore.
You would use it inside your .bat file like this:
Code:
WaitFileComplete -seconds 2 -retries 10 "%WD_FILE%"
... the rest of your original watchDirectory .bat file ...
 



The above command would check the file size every 2 seconds. If the size doesn't change 10 times in a row, WaitFileComplete will exit, and the remainder of your .bat file will run.

that should do it.

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


I love YaBB 1G - SP1!

Posts: 4
Re: Problem with FILEREN event
Reply #2 - Jan 24th, 2005 at 10:25pm
 
Thanks, Gert.

Since the batch program executed when the filename initially appeared in the directory, we were going to rename it after the upload was complete.  That's why we were looking at the FILEREN event.

At this time, it doesn't seem to lock the file until it is completely uploaded so I believe your suggestion about using the WaitFileComplete utility will be the way to go.  That way out upload process doesn't have to rename the file. 

Your WatchDirectory seems to be a great tool and I'm sure we will purchase it and maybe multiple copies for our internal use and our clients.

Thanks again for your help.
Stan
Back to top
 
 
IP Logged
 
stramels
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Re: Problem with FILEREN event
Reply #3 - Jan 24th, 2005 at 11:38pm
 
OK, Gert, I am having a bit of a problem with WaitFileComplete.exe.

I have added it to the beginning of my batch file:

set GdP="C:\Program Files\GdP Software\WatchDirectory"

rem Wait until file size has stopped growing.  Checks every 2 seconds and retries 10 times
rem before continuing the batch file
%GdP%\WaitFileComplete -seconds 2 -retries 10 -verbose %WD_FILE%

pause

The result I am getting is that it doesn't seem to understand the filename  (see below)
D:\SC_Video>set GdP="C:\Program Files\GdP Software\WatchDirectory"

D:\SC_Video>rem Wait until file size has stopped growing.  Checks every 2 seconds and retries 10 times

D:\SC_Video>rem before continuing the batch file

D:\SC_Video>"C:\Program Files\GdP Software\WatchDirectory"\WaitFileComplete -seconds 2 -retries 10 -verbose D:\SC_Video\MaxYld_Sacrifices.MPG
WaitFileComplete version 1.0.1, build Sat Sep  6 11:37:13 2003
(c) 2003, GdP Software (http://www.gdps.dk)
Monitors a file until it's size doesn't change anymore.

Don't understand D:\SC_Video\MaxYld_Sacrifices.MPG
Usage:
WaitFileComplete <options> filename
Valid options:
  -seconds 99   The number of seconds between checks
               If not specified, defaults to 10.
  -retries 99   The number of times the filesize should be
               the same before WaitFileComplete considers
               the file to be complete
               If not specified, defaults to 2.
  -verbose      Prints extra information while checking.

D:\SC_Video>pause
Press any key to continue . . .

Why does it not like %WD_FILE%.  That is the file that kicked off the FILENEW event.  I am monitoring the directory D:\SC_Video for a new file to show up.  The file that I am manually pasting into that directory is MaxYld_Sacrifices.MPG.  Any ideas?
Stan
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Problem with FILEREN event
Reply #4 - Jan 25th, 2005 at 3:53am
 
Stan,

Quote:
set GdP="C:\Program Files\GdP Software\WatchDirectory"


This is not really needed, the install directory (where watchDirectory is), is already available in the variable WD_INSTDIR.

Quote:
%GdP%\WaitFileComplete -seconds 2 -retries 10 -verbose %WD_FILE%


As you already "quoted" the GDP variable, this is resolved by windows as
Code:
"C:\Program Files\GdP Software\WatchDirectory"\WaitFileComplete ......
 


which seems an odd commandline.
When I try a commandline like you used (with the end-quote placed wrong), I get the same results as you do.
Please change it to
Code:
rem Wait until file size has stopped growing.  Checks every 2 seconds and retries 10 times
rem before continuing the batch file
"%WD_INSTDIR%\WaitFileComplete.EXE" -seconds 2 -retries 10 -verbose "%WD_FILE%"
 


Or, use the GDP variable as you did, but like this:
Code:
SET GdP=C:\Program Files\GdP Software\watchDirectory
rem Wait until file size has stopped growing.  Checks every 2 seconds and retries 10 times
rem before continuing the batch file
"%GdP%\WaitFileComplete.exe" -seconds 2 -retries 10 -verbose "%WD_FILE%"
 



Remember to put quotes around WD_FILE as well, because you never know when a file is created with a space in its name.

Hope this helps,
Gert
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
 
stramels
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Re: Problem with FILEREN event
Reply #5 - Jan 25th, 2005 at 3:29pm
 
Gert,
Your suggestions worked GREAT!
Thanks,
Stan
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1