Jump to content

FileGetTime


tazdev
 Share

Recommended Posts

Why I test the variables the YYYYDDMMHHMMSS on the $serverdate doesn't match what is the date. It is pulling the date the file was copied over. I want it to compare the dates of the first file with the server file, if the first one is newer (higher date number) then copy it over.

Anyone know what is wrong?

$serverdate = FileGetTime($serverfile, 1)
$linedate = FileGetTime($line, 1)
$serverfileexists = FileExists ($serverfile)
If $serverfileexists = 0 Then
      FileCopy($line, $serverfile,1)
Elseif $serverfileexists = 1 Then
    $linedate = $linedate[0]&$linedate[1]&$linedate[2]&$linedate[3]&$linedate[4]&$linedate[5]
      $serverdate = $serverdate[0]&$serverdate[1]&$serverdate[2]&$serverdate[3]&$serverdate[4]&$serverdate[5]
     If $linedate > $serverdate Then
         FileCopy($line, $serverfile,1)
     EndIf
EndIf
Link to comment
Share on other sites

Not sure, but redefining an array as a same-named single variable equal to its own elements seems a bit risky. Might be OK, to do this, but then might not. - Opinions, Gurus?

This one gets the time of a file in the standard AutoIt string format (which is YMD not YDM, BTW, otherwise numeric comparisons would be impossible. )

func FileDate($fdFile)
$fdTa = FileGetTime($fdFile)
if @error then
  MsgBox (0,"Date Error","Unable to get date of  " & $fdFile,10) 
  return "0"
endif
$fdDate = $fdTa[0] & $fdTa[1] & $fdTa[2] & $fdTa[3] & $fdTa[4] & $fdTa[5] 
return $fdDate
endfunc

Other point worth noting is that (according to MS) there is a small amount of "granularity" in file-times, therefore I'd allow a small increment in the comparison.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...