General discussion


Script that compare data file creation

By slava ·
How to create a script to compare the data
file creation?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Script that compare data file creation

by Steve Durbin In reply to Script that compare data ...

Assuming you mean "date of file creation" of two files, then a simple way is to use VBS and the FileSystemObject DateCreated property. Here's a
quick-and-dirty script to give an ERRORLEVEL return depending on the date compared:

Function getcreated(fname)
dim f
if myFSO.FileExists(fname) then
getcreated = myFSO.GetFile(fname).DateCreated
wscript.echo "ERROR: File '" + fname + "' does not exist"
end if
end Function

Dim myFSO, myArgs, fname, dt1, dt2
set myArgs = WScript.Arguments
if myArgs.Count <> 2 then
Wscript.Echo "Usage: [File1] [File2]"
end if
set myFSO = CreateObject("Scripting.FileSystemObject")
dt1 = getcreated( myArgs(0) )
dt2 = getcreated( myArgs(1) )
if dt1 = dt2 then
WScript.Echo "Same date"
end if
if dt1 > dt2 then
WScript.Echo "First file newer"
WScript.Echo "Second file newer"
end if

Related Discussions

Related Forums