No announcement yet.

BC Batch file to Log differences

  • Filter
  • Time
  • Show
Clear All
new posts

  • BC Batch file to Log differences

    Hello all,

    I am fairly new to BC and I have looked for this in the forums to no avail, so if the answer is there please forgive the repeated question.

    I am trying to write a script or preferably a batch file that will open BC, compare one or more of the sessions that it has saved in it, and then write to a log if there are any differences. I want this to be able to run in the background and only give an alert if there are differences.

    I have found a similar process for backing up, but not for comparing here. He mentions different commands that can be placed at the end of the bc file to do different jobs.

    Can some one point me at these commands or to another solution?


  • #2

    You could do this in either a single script, or a bat file that calls multiple scripts. Each line in a bc script is a single action, so you can have one script run through multiple loads and reports:
    load sessionName1
    folder-report ....
    load sessionName2

    Or you can setup a bat file, with multiple BC3 calls to script, and pass in parameters:
    bcompare.exe @"c:\script.txt" "sessionNameParameter1" "OtherParameter"
    bcompare.exe @"c:\script.txt" "sessionNameParameter2" "OtherParameter"
    then in the script, refer to the parameters with %1 and %2 (similar to a batch file).

    This is documented in the Help file under the Using Beyond Compare section -> Automating with Script.

    We also have a /silent argument, but I do not recommend using it until you are confident with how your script will behave. /silent will remove the feedback necessary to troubleshoot or investigate how your script is working.

    We have a "log" command in scripting, but this is for capturing the text of each command and any errors that may occur. The concept for reporting on a comparison is our "folder-report" command or "text-report" command, depending on if you want to display a) If the files are different as summary information on the folder or b) which text is equal/different in multiple pairs of selected files.
    You can generate both reports (and the wide variety of options they use) using the graphical interface in the Folder Compare session. Open a Folder Compare, issue an Expand All command, and then go to the Session menu -> Folder Comparison Report to see the variety of report types and options; or Select specific pairs of files and go to the Actions menu -> File Comparison Report to see the text-report report types and options. Once you have the type of report you want to generate, it will be easier to script the same report.

    Let us know if you have any questions.
    Aaron P Scooter Software


    • #3
      Thanks for the quick response. I will read over what you have said and get back to you, but so far it looks like this may fix me up just fine.



      • #4
        No problem. The other factor you may want to take into account is "criteria" (set before the load command). By default, this would compare your files using timestamp and size, but can be configured to perform a more detailed scan such as CRC, Binary, or Rules-based (as if you double clicked each file to view the contents).
        Aaron P Scooter Software


        • #5
          Ok, I am trying to use the Rules-based argument, but it seems that it may not be supported in version 2, or am I just doing this wrong.

          Here is the script I am sending to BC via Task Scheduler (found most of this in the help on my version of BC):

          #set up basic comparison features
          criteria rules-based
          #filter out log files
          filter "-\dir1\dir2\*.log"
          #load first comparison
          load GoogleMapping
          #generate a report of the differences
          folder-report layout:summary options:display-mismatches output-to:C:\wamp\www\backupScript\Logs\log.txt

          This is the result I get:

          Produced: 10/11/2010 9:02:57 AM

          Mode: Just Mismatches
          Left base folder: C:\wamp\www\Google Mapping
          Right base folder: Mapping

          Left Side Newer Files Size Modified

          Right Side Newer Files Size Modified

          Left Side Orphans Size Modified

          Right Side Orphans Size Modified
          elder2468.php 2,054 10/8/2010 2:48:15 pm
          elder2468.xml 290 10/8/2010 2:47:50 pm

          Contents Differ Size Modified
          AC_RunActiveContent.js 8,321 10/8/2010 2:03:40 pm
          8,029 10/8/2010 2:03:40 pm
          addFormUp.php 150 10/8/2010 2:11:32 pm
          146 10/8/2010 2:11:32 pm
          addPost.php 1,332 10/8/2010 5:26:43 pm
          1,303 10/8/2010 5:26:43 pm
          coorFormUp.php 150 10/8/2010 2:17:45 pm
          146 10/8/2010 2:17:45 pm
          coorMap.php 1,312 10/8/2010 2:41:44 pm
          1,276 10/8/2010 2:41:44 pm
          mapTemplate.php 2,101 10/8/2010 2:04:02 pm
          2,054 10/8/2010 2:04:02 pm
          MTW_loadXMLFile.php 294 10/8/2010 2:03:33 pm
          283 10/8/2010 2:03:33 pm

          Is that the right format for the script/log return?

          Last edited by Kalon; 11-Oct-2010, 08:20 AM.


          • #6
            My bad, I had the schedule running the wrong script. It works just as I needed. One more thing though, I have looked for a way to display the time spend running, if you don't run in silent mode the window that comes up shows you how long it took to run the comparison, but I can not get this to show in the log. Any ideas?



            • #7

              Right. The layout:summary is going to generate a Summary report. This report type will show a list of files that fall under a specific category.

              I would suggest loading your pair of folders in the graphical interface, and then pasting in your filter "string" (without quotes) into the filter toolbar in the upper right corner (defaults to "*.*").

              Then go to the Session menu -> Comparison Criteria and set the compare to use either Timestamp and Rules-based, or just Rules-based.

              Then use the Actions menu to generate different Folder Comparison Reports. The script options correlate directly to the different options you can select here, but by using the dialog you can see which options work together and quickly/easily generate a wide variety of different reports, without needing to recompare or run through the script. Once you have the report you want, you can then script that as your solution.

              Also, you may need an expand all command in your script, right below your load line. This would expose any items in subfolders. In the graphical interface, the expand all command is on the toolbar, and needs to be clicked before generating the report.
              Aaron P Scooter Software


              • #8
                Thanks for the help. The filters box is a great tool. Boss had me change to size report and we have the side by side in the layout with just the mismatches. The only thing left is the time it took to run. Is there a script command for that one? Can't seem to find it.



                • #9

                  For the first line of you script, try
                  log verbose "c:\folder\BCLog.txt"

                  This should create a log containing the timestamps and a "Script Completed in" line at the bottom. Does this meet your needs?
                  Aaron P Scooter Software


                  • #10
                    That will do nicely. Thank you.