Re: Windows Scripting - Timestamp, files, need help. :)

Tech-Archive recommends: Fix windows errors by optimizing your registry



I posted a script in a forum that looks in a directory and sub
directories to get file count. You should be able to modify to get the
timestamps of of the files. I would suggest that you look at the
FileSystemObject and its methods/properties for this.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/af4423b2-4ee8-41d6-a704-49926cd4d2e8.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/04b19915-6d68-4f3c-ac97-6a221daa8f83.asp

You may find something close that the ScriptingGuys from MS have put
together:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/files.mspx

Samantha wrote:
Hi there...

So, I've been Googling for days. I'm relatively new to programming
concepts - although I played with BASIC at the age of 8, and am
starting to tinker with Ruby, I have a task ahead of me with work that
I am losing my mind on. :)

In any case, I need to write a script in vbscript (I want to use
Windows Script Host) that does the following:

Goes into specified directory - let's call it E:\Data
Checks to see if there are any files.
If there are files present, checks to see what the timestamps are.
(likelihood is that there will be more than 1 file present if there are
any files at all.)
Gets the Highest (most recent timestamp) and compares it to the current
time.
If the most recent timestamp on the file is more than two hours old,
the script/program will send an email to a specified email address,
alerting that there are files present that are more than 2 hours old.

Sounds simple in theory, and probably is, but I can't get my head
wrapped around it.

I'm not too familiar with the syntax of vbscript, but I had a few
thoughts that I experimented with in Ruby...

Basically getting the current time, and formatting it YYYYMMDDHHMM
converting that to an integer...
getting all the timestamps from the files in the directory and putting
them into an array...
formatting each item in the array into the format YYYYMMDDHHMM
getting the Max (most recent timestamp) from the array...
and then, if currentTime - 200 > mostRecentTimeStamp having it trigger
off the email...

I hope I've been able to articulate myself properly. I am not asking
for anyone to write a script for me, but I'd love some guidance... I
have the 'logic' worked out in my head and on paper to a certain
extent... I could probably have someone write this for me at work, but
I wouldn't be learning anything then... :)

Thanks so much.

-S

.



Relevant Pages

  • Windows Scripting - Timestamp, files, need help. :)
    ... I need to write a script in vbscript (I want to use ... Gets the Highest (most recent timestamp) and compares it to the current ... and formatting it YYYYMMDDHHMM ... formatting each item in the array into the format YYYYMMDDHHMM ...
    (microsoft.public.scripting.vbscript)
  • subroutine references
    ... I'm working on yet another exercise from Intermediate Perl. ... were modified between the two timestamps. ... $stop variables in the script at large. ... When I run the script I get these error messages: ...
    (perl.beginners)
  • Re: Script help
    ... | And if the question was to tinker with a set of files ... be too many files to fit on a single command line? ... That the script calls ... Yes close timestamps are also an issue. ...
    (Fedora)
  • Re: script to copy file by timestamp
    ... This particular wheel has been invented some time ago in the ... While it is possible to do the same it VB Script, ... their timestamps"? ... Please clarify. ...
    (microsoft.public.windows.server.scripting)
  • Re: Dealing with Dates
    ... I can pull the record from the ... What I can't seem to do is collect the modified entries, ... The script below is the script I have so far. ... from my experience I really recommend using timestamps ...
    (php.general)