scripting@wanadoo.nl




CompareFileDates()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
26 March 2002 CompareFileDates()
AuthorScriptLogic Corporation
Action Compares the dates of two files.
SyntaxCompareFileDates ("file1", ["file2"]) 
Parameters
  • file1 (Required / String) Identifies the first file you want to compare.
  • file2 (Optional / String) Identifies the second file you want to compare. If file2 is not specified, file1 will be compared to today's date. 
  • RemarksSimilar in function to KiXtart's built-in CompareFileTimes() function, except this UDF compares the date-only portion of the each file's timestamp. Useful when comparing a file on an NTFS partition with a file located on a FAT partition, due to the 2-second rounding issue in Windows. 
    Returns-3 File2 could not be opened.
    -2 File1 could not be opened.
    -1 File1 is older than file2.
    0 File1 and file2 have the same date
    1 File1 is more recent than file2. 
    DependenciesSerialDate() 
    Examples
    $rc=CompareFileDates('@Lserver\netlogon\kix32.exe','%WINDIR%\kix32.exe')
    IF $rc=1
      ? 'I need to update the copy of KiX32.exe on your local machine'
    ENDIF
    
     
    Source
    FUNCTION CompareFileTimes ($file1, OPTIONAL $file2)
      ; Author: ScriptLogic Corporation
      ; Similar in function to KiXtart's built-in CompareFileTimes()
      ; function, except this compares the date-only portion of each
      ; file's timestamp. if $File2 is not specified, $file1 will be
      ; compared to today's date.
      ; requires SerialDate() UDF from www.scriptlogic.com/kixtart
    
      DIM $file1sdate, $file2sdate
      $file1date=''+GetFileTime($file1)
      IF @error ; possible file not found
        $comparefiledates=-2
        RETURN
      ELSE
        $file1sdate=serialdate(Substr($file1date,1,10))
      ENDIF
      IF (''+$file2 = '')
        $file2sdate=serialdate(@date)
      ELSE
        $file2date=''+GetFileTime($file2)
        IF @error ; possible file not found
          $comparefiledates=-3
          RETURN
        ELSE
          $file2sdate=serialdate(Substr($file2date,1,10))
        ENDIF
      ENDIF
      SELECT
        CASE ($file1sdate < $file2sdate)
          $comparefiledates=-1
        CASE ($file1sdate = $file2sdate)
          $comparefiledates=0
        CASE ($file1sdate > $file2sdate)
          $comparefiledates=1
        CASE 1 ; unexpected result
          $comparefiledates=-5
      ENDSELECT
    ENDFUNCTION ; - CompareFileDates -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter