I am writing a macro that monitors a file folder for files that are at least two minutes old. I have gotten some help on this already but this relates to something else so I am posting a new message
The script below parses the file name and time from a text file. (I will add the line to only create the text file if a file exists in the directory - exit loop)
The script is based on the minutes of the day. So, if an old file is copied in it many not work until later (there are other difficulties depending upon how often the folder is set to be monitored, such as once a day, and an old file would never make it based on minutes.
I was thinking of elapsed time from a given date such as 12:01 AM 2000. If I compared the elapsed time of the file creation to that date and time, and then the elapsed time from 12:01 AM 2000 to the present time it should always work as long as the file is not older than 12:01 AM 2000.
Anyways, I have read about the options in VB Script and it looks like it could be done in this fashion. However, I am a little clueless about how to do it. Is there in the datediff a way to enter an entire date, such as the date information from the file and come back with minutes from a given point. It there is it would save so much logic as looking at days in the month, what year etc.
Any ideas on how to do this? Or is there something in my logic that makes this not work?
Since this script works on parsing text from a file it may be of help to others
ReadIniFile>C:\ScrapeLOS\ScrapeLOS.ini,Path,Path,ProcessPath
IfFileExists>C:\ScrapeLOS\tempflist.txt
Deletefile>C:\ScrapeLOS\tempflist.txt
Endif
Let>RP_WINDOWMODE=0
Let>RP_WAIT=1
Run Program>cmd.exe /c dir %ProcessPath% /aa > C:\ScrapeLOS\tempflist.txt
Let>RP_WAIT=0
Let>f=1
Label>starttimeloop
ReadLn>C:\ScrapeLOS\tempflist.txt,f,line
If>line=##EOF##,finishtimeloop
If>f>5
Position>File(s),line,1,listdone
If>listdone>1
Goto>finishtimeloop
Endif
////////////////////////////////////Begin to Parse line
/MDL>line
/////////////////////////////////////////////////////////////////////////////////Get Month
MidStr>line,1,2,fileMonth
Position>0,fileMonth,1,dfileMonth
If>dfileMonth=1
MidStr>line,2,1,fileMonth
Endif
/////////////////////////////////////////////////////////////////////////////////Get Day
MidStr>line,4,2,fileDay
Position>0,fileday,1,dfileDay
If>dfileDay=1
MidStr>line,5,1,fileDay
Endif
////////////////////////////////////////////////////////////////////////////////Get Year
MidStr>line,7,4,fileYear
////////////////////////////////////////////////////////////////////////////////Get Hour
MidStr>line,13,2,fileHour
Position>0,fileHour,1,dfileHour
If>dfileHour=1
MidStr>line,14,1,fileHour
Endif
////////////////////////////////////////////Get Minute
MidStr>line,16,2,fileMinute
Position>0,fileMinute,1,dfileMinute
If>dfileMinute=1
MidStr>line,17,1,fileMinute
Endif
MidStr>line,19,2,fileAMPM
IF>fileAMPM=PM
Let>fileHour=%fileHour% + 12
Endif
VBSTART
Function MultiplyNums (d,a)
MultiplyNums = d * a
End Function
VBEnd
VBEval>MultiplyNums(%fileHour%,60),dayminutes
Let>fileMinute=%fileminute% + %dayminutes%
Let>fileMinute=%fileminute% + 2
VBSTART
VBEND
VBeval>Year(Now),ThisYear
VBeval>Month(Now),ThisMonth
VBeval>Day(Now),ThisDay
VBeval>Hour(Now),ThisHour
VBeval>Minute(Now),ThisMinute
VBEval>MultiplyNums(%ThisHour%,60),Thisdayminutes
Let>Thisdayminutes=%Thisdayminutes%+%ThisMinute%
/MessageModal>File Month %fileMonth%%CRLF%File Day %fileday%%CRLF%File Year %fileyear%%CRLF%File hour %filehour%%CRLF%File Minute %fileMinute%%CRLF%Hours in Minutes %dayminutes%%CRLF%File creation %fileAMPM%
If>Thisdayminutes>%fileminute%
MDL>This file is is more than two minutes older %CRLF%%Line%%CRLF%This minute %Thisdayminutes%%CRLF%File Minute %fileminute%
Endif
///////////////////////////////////End Parse Line
Endif
Let>f=f+1
Goto>starttimeloop
Label>finishtimeloop