I was able to write a FTP script to download logfiles from a server and
it works well. The problem is it grabs all the files.

I only want to retrieve the logfile that is 1 day old. Everyday.
Basically grabbing the file from the night before.

I wish there was a "get yesterdays dated file" variable

Re: FTP file that is 1 day old? by James

James
Thu Dec 01 16:59:01 CST 2005

"gmedia" <gschaef1@cablevision.com> wrote in message
news:1133472929.708056.182760@f14g2000cwb.googlegroups.com...
> I was able to write a FTP script to download logfiles from a server and
> it works well. The problem is it grabs all the files.
>
> I only want to retrieve the logfile that is 1 day old. Everyday.
> Basically grabbing the file from the night before.
>
> I wish there was a "get yesterdays dated file" variable

Take a look at the code below. This should give you an idea of how to act
on filenames with a date that is a certain numbers of days old. Change up
the example filename in the <sFileName = "20051130.dat"> line to see the
results.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim oRegEx
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Pattern = "^(\d{4})(\d{2})(\d{2})\..*$"

sFileName = "20051130.dat"

If oRegEx.Test(sFileName) Then
sFileName = oRegEx.Replace(sFileName, "$2/$3/$1")
sFileName = CDate(sFileName)
End If

MsgBox DateDiff("d", sFileName, Now())
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you need help creating the actual compare and copy loop, just reply to
this thread or your previous thread.



Re: FTP file that is 1 day old? by Michael

Michael
Thu Dec 01 19:59:23 CST 2005

On 1 Dec 2005 13:35:29 -0800, "gmedia" wrote in
microsoft.public.scripting.vbscript:

>I was able to write a FTP script to download logfiles from a server and
>it works well. The problem is it grabs all the files.
>
>I only want to retrieve the logfile that is 1 day old. Everyday.
>Basically grabbing the file from the night before.
>
>I wish there was a "get yesterdays dated file" variable

There is - in a proper CLI. In 4NT (a commercial product):

COPY /[d-1] "ftp://server/dir/file.ext"

will copy files modified yesterday or today. 4NT's Date Ranges are
documented at <http://jpsoft.com/help/dateranges.htm>; 4NT's transparent
FTP support is described at <http://jpsoft.com/help/ftpservers.htm>.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"