Alert if files have been in folder for X

Microsoft Windows xp professional editio...
October 8, 2009 at 15:54:12
Specs: Windows XP
I have a process that places XML files in to a directory, I have another process that takes these files out.

I am trying to work out how best to monitor the folder and generate an alert to "Alert these files have been waiting in this directory for 30+ minutes"

I was looking at the created dates of the file but as these files are created on another system some times the dates and times can be way off and creating alerts for no reason. I was thinkign if it might be possible to some how do a crc check or some other way to monitor this folder.


See More: Alert if files have been in folder for X

Report •


#1
October 8, 2009 at 16:43:08
The hard part is the 'date math'.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
October 8, 2009 at 17:00:08
I am trying a few things testing with crc


; Generated on 10/09/09 at 10:47:10
;
59d0b77f ?CRC32*file1.xml
58d0b77l ?CRC32*file2.xml


Mybe get the content of the folder write it to a file and then get the content of files again in 60 minutes and then compare them and see if the files are still there. Its a bit of a hard one.


Report •

#3
October 8, 2009 at 17:57:17
Are the file names the same from file to file?

Report •

Related Solutions

#4
October 8, 2009 at 19:16:22
I think you hit on some thing that I did not think of here is an
example of files that might appear.

02_021009112001_00000001.xml
02_021009112001_00000002.xml
02_021009112001_00000003.xml

01_011008190100_00000001.xml
01_011008190100_00000002.xml
01_011008190100_00000003.xml
01_011008190100_00000004.xml

01_01 or 02_02

First 4 digits are either 01_01 or 02_02 this in reference to where it came from eg server1 or server2.

Next is a date and time stamp

1009112001
1008190100

MMDDHHMMSS

The last part is just a sequential number.

A batch of files might be created at 11:30am that where sent from server 1 the batch might be 1000 files in total.

01_011009113000_00000001.xml first file
01_011009113000_00001000.xml last file

If file name part "10-09 11:30" and time = 12:30 then echo "Alarm"


Report •

#5
October 8, 2009 at 19:41:04
Like I said the date math is the hard part.

If you just want to check for any change in folder, no need for crc:

============================
@echo off & setLocal EnableDELAYedExpansion

if not exist %temp%\# dir | find /i /v "free" > %temp%\#

dir | find /i /v "free" > %temp%\##

fc %temp%\# %temp%\## > nul
if errorlevel 1 (
echo changed
) else (
echo no change
)
)
dir | find /i /v "free" > %temp%\#


=====================================
Helping others achieve escape felicity

M2


Report •

#6
October 8, 2009 at 20:02:28
Thanks M2 yer I might have to use some thing with more "Brains"

PS nice script


Report •

#7
October 11, 2009 at 20:32:11
If you are not averse to using Qbasic, the following might
work:

D$ = DATE$
D$ = LEFT$(D$, 2) + MID$(D$, 4, 2)
T$ = TIME$
D$ = D$ + LEFT$(T$, 2) + MID$(T$, 4, 2) + MID$(T$, 7, 2)
'this creates a "dummy" file with current date+time as its
'name. Everything below that file in a reverse-sorted dir
'should be needing older than that file.
'(just guessing how many zeros needed, if any, in foll.line)
F$ = "00_00" + D$ + "_0000000000.zzz"
OPEN "D.BAT" FOR OUTPUT AS #1
PRINT #1, "ECHO A > " + CHR$(34) + F$ + CHR$(34)
PRINT #1, "DIR /B | SORT /+6 /R > DIRLIST"
CLOSE #1
SHELL "D.BAT"
OPEN "DIRLIST" FOR INPUT AS #1
PFLAG = 0
DO WHILE NOT EOF(1)
LINE INPUT #1, K$
P = INSTR(K$, F$)
IF PFLAG = 1 THEN PRINT "ALERT: "; K$
IF P > 0 THEN PFLAG = 1
LOOP
CLOSE
END

QB can be compiled into .exe using BC and LINK
Batchfiles are more of a challenge because they have less
"brains", but sometimes you just have to resign yourself
to using VisBasic or Qbasic or other languages.


Report •


Ask Question