I am a new at VBScripting and need some help...I am trying to create a script that will monitor a folder for any file older than 1 hour, this is what I have so far:
'Desc :Check files age
' Return age of files in the folder, -1 if it encounter error.
'USAGE :FNChkFileAge [path] [file]
'
Dim Fname,oShell, FSO
path = Wscript.Arguments(0)
file = Wscript.Arguments(1)
' Create a FileSystemObject and use it to check
' if the file exists
'
Set FSO= CreateObject("Scripting.FileSystemObject")
set Fname = FSO.GetFile(path & "\" & file)
wscript.echo Fname & " created on: " & Fname.DateCreated
wscript.echo Fname & " last updated: " & Fname.DateLastModified
wscript.echo "Current datetime: " & now()
wscript.echo "Current date: " & date
dFileModDate = Fname.DateLastModified
FileAge = DateDiff("h", dFileModDate, Now)
wscript.echo "FileAge: " & FileAge
If DateDiff("h", dFileModDate, Now) > 1 Then
wscript.echo "Warning: File idled for more than 1 hour!"
End If
'FileAge = now() - Fname.DateCreated
'wscript.echo FileAge
'wscript.echo "yr " & year(fileage)
'wscript.echo "hour " & hour(fileage)
'wscript.echo "mm " & minute(fileage)
wscript.quit
Any help is apriciated. TIA.
'Desc :Check files age
' Return age of files in the folder, -1 if it encounter error.
'USAGE :FNChkFileAge [path] [file]
'
Dim Fname,oShell, FSO
path = Wscript.Arguments(0)
file = Wscript.Arguments(1)
' Create a FileSystemObject and use it to check
' if the file exists
'
Set FSO= CreateObject("Scripting.FileSystemObject")
set Fname = FSO.GetFile(path & "\" & file)
wscript.echo Fname & " created on: " & Fname.DateCreated
wscript.echo Fname & " last updated: " & Fname.DateLastModified
wscript.echo "Current datetime: " & now()
wscript.echo "Current date: " & date
dFileModDate = Fname.DateLastModified
FileAge = DateDiff("h", dFileModDate, Now)
wscript.echo "FileAge: " & FileAge
If DateDiff("h", dFileModDate, Now) > 1 Then
wscript.echo "Warning: File idled for more than 1 hour!"
End If
'FileAge = now() - Fname.DateCreated
'wscript.echo FileAge
'wscript.echo "yr " & year(fileage)
'wscript.echo "hour " & hour(fileage)
'wscript.echo "mm " & minute(fileage)
wscript.quit
Any help is apriciated. TIA.