Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update Local file based on time modified comparison
#1
Hi All,
I have a local db file that I want to check against a network copy for any updates. I wrote this script (see below) to compare the time modified and used the DateTime function to help with numerical comparison. I am assuming that the larger number represents the more recent file. Will that always be true?
I could do more testing but thought I would post the code here and see if anyone knows more elegant way.

Thanks!!! S

Function UpdateDb
Code:
Copy      Help
str- NetworkDbFile="\\NetworkLocation\AdminDB.db3"
str- LocalDbFile="$common documents$\AdminDB.db3"

if(!dir(LocalDbFile));;if local copy does not exist
,out "Copying AdminDb from network....."
,cop- NetworkDbFile LocalDbFile; err ErrMsg(1)
,out "Copying AdminDb.....done."
,
Dir d1
if d1.dir(NetworkDbFile 0) ;;if exists
,DATE dNetworkTimeMod=d1.TimeModified2
,
Dir d2
if d2.dir(LocalDbFile 0) ;;if exists
,DATE dLocalTimeMod=d2.TimeModified2


out NetworkTimeMod
out LocalTimeMod

DateTime dtNetworkTimeMod.FromDATE(dNetworkTimeMod)
DateTime dtLocalTimeMod.FromDATE(dLocalTimeMod)

out dtNetworkTimeMod
out dtLocalTimeMod
;
if dtNetworkTimeMod > dtLocalTimeMod
,cop- NetworkDbFile LocalDbFile; err ErrMsg(1)
,


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)