Announcement

Collapse
No announcement yet.

Not getting expected results with a scripted compare

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Not getting expected results with a scripted compare

    Hi,

    Although I have used BC for several years, this is my first attempt at scripting.
    Probably this is an error in understanding how the scripting language works

    Here is a script that I generate and run

    # beyond compare script generated by c:\ooRexx\makeHotkeyUpdate.rex 2 Aug 2010 14:27:21
    # This script produces a hotkey auto update zip file
    # and keeps the master source up to date.
    #
    log verbose c:\logs\bcHotkey.log
    option confirm:yes-to-all
    # compare using crc
    criteria timestamp:6sec;IgnoreDST crc
    # Load the default session and exclude most file types
    load <default>
    filter "*.bmp;*.kbm;-local*.kbm"
    # load current files against Master Source
    load "C:\temp\BCTest\Dev\System" "C:\temp\BCTest\MasterSource\System"
    # expand to affect subfolders and files
    expand all
    # select updated files
    select lt.newer.files lt.orphan.files
    # copy changes to a .zip file
    copyto lt path:relative "C:\temp\BCTest\FTPsite\Hotkeys\2010-08-02.zip"
    # print summary of files involved
    folder-report layout:summary &
    options:display-left-newer-orphans,column-none &
    output-to:"C:\DOCUME~1\saha\LOCALS~1\Temp\HotKeyList.txt "
    # now update the master source
    sync update:left->right



    Here is the log of it running

    02/08/2010 14:27:22 >> load <default>
    02/08/2010 14:27:22 >> filter "*.bmp;*.kbm;-local*.kbm"
    02/08/2010 14:27:22 >> # load current files against Master Source
    02/08/2010 14:27:22 >> load "C:\temp\BCTest\Dev\System" "C:\temp\BCTest\MasterSource\System"
    02/08/2010 14:27:24 Load comparison: C:\temp\BCTest\Dev\System <-> C:\temp\BCTest\MasterSource\System
    02/08/2010 14:27:24 >> # expand to affect subfolders and files
    02/08/2010 14:27:24 >> expand all
    02/08/2010 14:27:24 >> # select updated files
    02/08/2010 14:27:24 >> select lt.newer.files lt.orphan.files
    02/08/2010 14:27:24 >> # copy changes to a .zip file
    02/08/2010 14:27:24 >> copyto lt path:relative "C:\temp\BCTest\FTPsite\Hotkeys\2010-08-02.zip"
    02/08/2010 14:27:24 Copied C:\temp\BCTest\Dev\System\Bitmaps\JSGP902.bmp to C:\temp\BCTest\FTPsite\Hotkeys\2010-08-02.zip
    02/08/2010 14:27:24 Successfully copied 1 items. Completed in 0.03 seconds.
    02/08/2010 14:27:24 >> # print summary of files involved
    02/08/2010 14:27:24 >> folder-report layout:summary &
    02/08/2010 14:27:24 >> options:display-left-newer-orphans,column-none &
    02/08/2010 14:27:24 >> output-to:"C:\DOCUME~1\saha\LOCALS~1\Temp\HotKeyList.txt "
    02/08/2010 14:27:24 >> # now update the master source
    02/08/2010 14:27:24 >> sync update:left->right
    02/08/2010 14:27:24 Copied C:\temp\BCTest\Dev\System\Bitmaps\JSGP902.bmp to C:\temp\BCTest\MasterSource\System\Bitmaps
    02/08/2010 14:27:24 Successfully synchronized 1 items. Completed in 0 seconds.
    02/08/2010 14:27:24 Script completed in 1.88 seconds


    and the log

    Folder Compare
    Produced: 02/08/2010 14:27:24

    Mode: Left Newer and Left Orphans
    Filters: *.bmp;*.kbm;-local*.kbm
    Left base folder: C:\temp\BCTest\Dev\System
    Right base folder: C:\temp\BCTest\MasterSource\System

    Left Orphan Files (1)
    ---------------------
    Bitmaps\JSGP902.bmp
    ---------------------

    Left Newer Files (0)
    ---------------------

    I expect it to find 1 file different (newer) and one orphan against this test data, but it is onlyfinding the orphan.

    If I compare the folders using the GUI interface the different file is located using a CRC comparison

    Here is a DIR for the lefthand file


    C:\temp\BCTest\Dev\System\kbm>dir boxes.kbm
    Volume in drive C is OS
    Volume Serial Number is 0AE2-19CA

    Directory of C:\temp\BCTest\Dev\System\kbm

    02/08/2010 14:20 5,513 boxes.kbm

    and here is one for the righthand file


    C:\temp\BCTest\MasterSource\System\kbm>dir boxes.kbm
    Volume in drive C is OS
    Volume Serial Number is 0AE2-19CA

    Directory of C:\temp\BCTest\MasterSource\System\kbm

    10/07/2006 15:25 5,513 boxes.kbm
    1 File(s) 5,513 bytes


    showing they have considerably different file dates.

    And here is the result of a ‘dos’ fc command showing they have different contents:

    C:\temp\BCTest\MasterSource\System\kbm>fc boxes.kbm ..\..\..\dev\System\kbm\boxe
    s.kbm
    Comparing files boxes.kbm and ..\..\..\DEV\SYSTEM\KBM\BOXES.KBM
    ***** boxes.kbm
    053,053,[10][03]JSGJ302[01],1,C:\TILL\SYSTEM\BITMAPS\JSGJ302.bmp,1
    054,054,[10][03]JSGP901[01],1,C:\TILL\SYSTEM\BITMAPS\JSGP901.bmp,1
    055,055
    ***** ..\..\..\DEV\SYSTEM\KBM\BOXES.KBM
    053,053,[10][03]JSGJ302[01],1,C:\TILL\SYSTEM\BITMAPS\JSGJ302.bmp,1
    054,054,[10][03]JSGP902[01],1,C:\TILL\SYSTEM\BITMAPS\JSGP902.bmp,1
    055,055
    *****


    I would expect the line

    criteria timestamp:6sec;IgnoreDST crc
    To look for differences in the timestamp OR crc and in this case I think we should get a hit on both counts

    I would also expect the line
    select lt.newer.files lt.orphan.files
    to select BOTH left.newer.files AND left.orphan.files



    Is that not correct?

    Thanks for any help you can give me
    BC 3.1.11 (build 12204) Windows XP – all files are on local disks.

  • #2
    Almost as soon as I posted this I worked out that what I had to do was to add
    lt.diff.files
    to the select statement, and that worked.

    However, I don't understand why lt.newer.files did not pick up the amended file as it was several years newer than it's equivalent on the right.

    thanks,

    Jon

    Comment


    • #3
      You should change the order of the criteria and "load <default>" commands.

      # Load the default session and exclude most file types
      load <default>

      # compare using crc
      criteria timestamp:6sec;IgnoreDST crc

      A saved session includes criteria, so if you load a session after specifying the criteria, it is overridden.

      Also, "sync update" only copies orphan files and files with newer timestamps. This is why files with only CRC differences are not copied. "sync mirror" will copy files with any differences, including newer, older, orphan, and files with content differences, including CRC. Be aware that "sync mirror" will also delete orphan files on the target folder.
      Chris K Scooter Software

      Comment


      • #4
        Thanks Chris,

        both points were there in the manual if I'd only looked.

        I have changed the script and it now does what I expected.

        Jon

        Code:
        # beyond compare script generated by c:\ooRexx\makeHotkeyUpdate.rex 3 Aug 2010 05:56:07
        # This script produces a hotkey auto update zip file
        # and keeps the master source up to date.
        # 
          log verbose c:\logs\bcHotkey.log
          option confirm:yes-to-all
        # Load the default session
          load <default>
        # compare using crc
          criteria timestamp:6sec;IgnoreDST crc
        # exclude most file types
          filter "*.bmp;*.kbm;-local*.kbm"
        # load current files against Master Source
          load "C:\temp\BCTest\Dev\System" "C:\temp\BCTest\MasterSource\System"
        # expand to affect subfolders and files
          expand all
        # select updated files
          select lt.newer.files lt.diff.files lt.orphan.files
        # copy changes to a .zip file
          copyto lt path:relative "C:\temp\BCTest\FTPsite\Hotkeys\2010-08-03.zip"
        # now update the master source
          copy left->right
        # print summary of files involved
          folder-report layout:summary                     &
            options:display-left-newer-orphans,column-none &
            output-to:"C:\DOCUME~1\saha\LOCALS~1\Temp\HotKeyList.txt"

        Comment

        Working...
        X