Multiple Parameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • captedgar
    Enthusiast
    • Nov 2009
    • 31

    Multiple Parameters

    Hi there

    I have the following problem which i have elaborated as much as possible.

    I have a batch file which performs the sync process between 2 servers. One of the steps in the batch file is to call beyond compare application and perform compare between 2 folders, backup mismatches and sync up the mismatches. The following step is what i have written above extracted from my main batch file

    rem Compare the Sakiv directory between the 2 servers
    Echo Step5 = Comparing Sakiv Folder between %1 and %2. Any Difference in File on %1 will be backedup before syncing with %2...........
    Call C:\Sync\Compare\CompareSakivFolder.bat

    The contents of CompareSakivFolder.bat file is as follows
    --------------------------------------------------------------------------
    call C:\Sync\Compare\BCSakiv.bat "%1\c$\sakiv" "%2\c$\sakiv"
    --------------------------------------------------------------------------

    The contents of BCSakiv.bat file is as follows
    --------------------------------------------------------------------------
    echo off
    "\\tide1\c$\Program Files\Beyond Compare 3\BCompare.exe" @"C:\Sync\Compare\CompareSakiv.txt"
    IF %ERRORLEVEL% == 9009 GOTO BeyondCompareNotFoundError
    GOTO end

    :BeyondCompareNotFoundError
    cls
    echo ----------SCRIPT FAILURE-------------
    echo BCompare.exe was not found under
    echo C:\Program Files\Beyond Compare 3\
    echo or script file not found
    pause
    GOTO end

    :end
    --------------------------------------------------------------------------
    The contents of CompareSakiv.txt file is as follows

    # INPUT:
    # %1: ServerName A which requires Sync Up from LIVE Server i.e. ServerName B
    # %2: ServerName B which will sync to ServerName A

    # Load the base folders
    load %1 "\c$\Sakiv" %2 "\c$\sakiv"

    # Set the filters
    filter "-*sprew*.*;-\splash\;-*WireCon-*.*;-DBrigl.ini;-TAreas.xsl"

    #expand to affect subfolders and files
    expand all

    #Confirm if needed to override
    option confirm:yes-to-all

    #Criterias for compare
    criteria size, modified

    #Compare using binary if not crc
    compare binary

    #select mismatched files
    select lt.diff.files lt.orphan.files

    #copy files that have changed on the server to sync up i.e. servername A, when compared to the LIVE server i.e. servername B
    copyto lt path:relative "\\%1\c$\Sync\Compare\sakiv_%t%"

    # Copy different files right to left
    sync create-empty update:right->left

    # HTML Report
    file-report layout:Summary &
    options:display-mismatches,column-CRC,column-version,column-Modified &
    output-to:%3 output-options:html-color %1 %2
    title:sakiv Compare
    --------------------------------------------------------------------------

    The problem is when i run my main batch file, i get an error from the beyond compare application which is called unable to load the base folders. fatal error in scripts. scripts will now close.

    I have 2 more folders to compare i.e. volcano and quake other then sakiv(all folders renamed here for security reasons). They all have the relevent batchfiles and script files too.

    I'm just wondering if there is a better way to do this really

    please help

    regards
  • Aaron
    Team Scooter
    • Oct 2007
    • 15995

    #2
    Hello,

    To use the BAT paramaters, you need to pass them into BC on the command line:
    "\\tide1\c$\Program Files\Beyond Compare 3\BCompare.exe" @"C:\Sync\Compare\CompareSakiv.txt" %1 %2


    When you see example scripts with BC, the %1 and %2 are our own parameters. You could as easily call from the command line:
    bcompare.exe @script.txt c:\folderA c:\folderB
    and in script.txt you can refer to c:\folderA with %1 and c:\folderB with %2. These happen to be the same symbols used with Bat variables.

    Also, it looks like you have a space character after your %1 reference. You probably need to close that
    Your load command should simply load your two folders. You seem to have:
    load "%1\c$\Sakiv" "%2\c$\sakiv"


    That's for the error. A couple of other things I noticed about your script:
    the filter and criteria command lines should come before load. This will make the load command faster.

    The compare command is performed on a selection. Do you want all files to have a binary comparison done? If so, you should use a criteria binary before the load command.

    The file-report command takes in two files as parameters, or works on a selection. You cannot pass it two folder names. Instead perform another select command on the files you want file reports with, or use the folder-report command.

    **I also always recommend performing script tests on already backed up or test data, until you are more comfortable with how the script is going to affect your data.

    Does that help? Let us know if you have any questions.
    Aaron P Scooter Software

    Comment

    • captedgar
      Enthusiast
      • Nov 2009
      • 31

      #3
      Thanks Aaron. This helped. very helpful of you to advice

      Comment

      Working...