Scripting with Data Compare session

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DouglasVaughan
    New User
    • Aug 2014
    • 1

    Scripting with Data Compare session

    I'm fairly new to the more advanced features of Beyond Compare, although I've been using the tool for generic text comparisons for a while.

    I'm trying to set up an automated process to compare a variant file against a known baseline. To manually compare these two files I've created a data compare session and it works pretty well. Now I'd like to create a Beyond Compare script to kick the process off silently. Researching through these forums I've formed the understanding that this might not be possible without an extensive work around involving a portable installation and/or some sort of parent/child folder arrangement. Is this accurate?

    I'm using Beyond Compare Standard at v3.3.12.18414
  • Aaron
    Team Scooter
    • Oct 2007
    • 15985

    #2
    This would depend on the customization needed. BC Scripting can call "data-report" with two file names as parameters, and generate a report using the default Data Compare session settings and file format. You can create a new File Format to match on your specific files or file mask, which the topmost match in the File Formats dialog is the one used automatically during a script call (or rules-based compare in the graphical interface).

    You would then need to update the Session Defaults for the Data Compare to work for your report. This is the step where, if this needs to change each script call, needs the more extensive customization of the BCSessions.xml.

    Does using default session settings, a possible File Format, and the data-report script call work for you?

    Code:
    data-report layout:side-by-side options:display-mismatches,line-numbers output-to:"c:\bcreport.html" output-options:html-color "c:\file1.csv" "c:\file2.csv"
    Aaron P Scooter Software

    Comment

    • DouglasVaughan
      New User
      • Aug 2014
      • 1

      #3
      I've got 12 or so different delimited/fixed width files that will each need to be compared to their own unique baseline file. Each file contains different data, so the key/unimportant columns will differ between the 12 files. However the key/unimportant columns will remain consistent for each individual file.

      As per my understanding, the only means to declare columns as key/unimportant is through the session settings. I assume the customization to the XML would be directly modifying the parameter settings in the default session prior to performing the comparison. The only other option would be to have a separate install with the proper session settings for each document.

      Thank you for clarifying.

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15985

        #4
        Correct. If Key columns need to be modified on the fly, we don't currently support this, but our BCSessions.xml could be externally modified before calling the bcscript. The Portable Install just insures that, whichever Windows Account is running the script uses the BCSessions.xml within the install folder, rather than in it's own %AppData% folder.
        Aaron P Scooter Software

        Comment

        • retesh101
          Visitor
          • Nov 2014
          • 4

          #5
          Hello Aaron,

          I have similler setup, can you advise me how to save the session settings in xml and then call it here?

          %BCompare%\BCompare.exe "@%BCompare%\bcscript.txt" "%folder5%\%%~F" "%folder6%\%%~F" "%folder7%\%%~F.html" "/silent"

          this is what i have in bcscript.txt
          file-report layout:side-by-side options:display-mismatches output-to:"%3" output-options:html-color "%1" "%2"

          Thanks,
          Retesh

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 15985

            #6
            Hello,

            There isn't a method to 'call' the saved .XML as part of a specific command line. It needs to be set ahead of time (using another scripting language or setting it in the GUI), then call the script normally, which then uses the defaults.

            To generate an XML to use, I recommend configuring it in the GUI, using a new, blank Folder Compare. Load up your folders, then alter the Session menu -> Session Settings dialog. Once that is working, go back to this dialog and at the bottom, update from "Use only for this view" to "Also update session defaults".

            Once updated, you can find the BCSessions.xml with the correct default settings using the Help menu -> Support dialog, Explore Settings folder link. This will auto-generate all of the correct syntax specific to your version of Beyond Compare, and also let you verify it in the GUI.

            For any script troubleshooting, I recommend removing /silent. Silent suppresses all dialogs, including error dialogs, which are useful for monitoring the action. Once it is working as expected, add /silent back in.
            Aaron P Scooter Software

            Comment

            • retesh101
              Visitor
              • Nov 2014
              • 4

              #7
              Thanks a lot Aaron !!! that worked like a charm...

              best regards
              Retesh

              Comment

              • AjitPandey
                Journeyman
                • Oct 2015
                • 12

                #8
                My objective is to compare 2 files keeping certain Keys as combined primary key. What I did was saved the settings as Session - "TestMySession". The problem now is that file name is different every single day. Is there a way I can pass my file name to compare using the saved session using scripting without have to open the XML BCSessions.xml manually and then running the session.

                Comment

                • Aaron
                  Team Scooter
                  • Oct 2007
                  • 15985

                  #9
                  Hello,

                  Not easily. We don't support loading a Data Compare session and then loading files.

                  The scripted workaround would be to have a saved Folder Compare, with a saved child Data Compare (from a Folder Compare, double click a data file, and update the Session Settings and Use for All Files dropdown, then save the Folder Compare). Now if you script load the Folder Compare, and have file name filters to only show the files you want to generate a report on, and they are aligned (same name or Alignment Override defined), you can then select them using the select script command, then perform a data-report script command on the selection.

                  Depending on how often you need to update Key values, it may be easier to update the .xml directly to update the Session Defaults, then perform a data-report in script.
                  Aaron P Scooter Software

                  Comment

                  • AjitPandey
                    Journeyman
                    • Oct 2015
                    • 12

                    #10
                    Thanks Aaron. So if my folder also changes along with file, I basically need to update the values with new files paths of "Left" and "Right" XPath of XML using some other scripting.

                    Comment

                    • Aaron
                      Team Scooter
                      • Oct 2007
                      • 15985

                      #11
                      Hello,

                      If you are using the folder method, we actually support loading different folders in a saved folder compare, but you would need to have saved it with "Use for All files within session" and not "Use for specific files in parent session". This is done by loading the session first, then loading a folder pair:

                      load "Session name"
                      load "c:\folder1" "c:\folder2"

                      This loads the two folders into the previously loaded session.

                      If you are familiar with any other scripting to alter an xml, it is probably easier to modify the default session settings of a Data Compare within the BCSessions.xml, then the BC side of the scripting would be a single command: data-report layout:side-by-side output-to:"c:\bcreport.txt" "c:\file1.csv" "c:\file2.csv"
                      Aaron P Scooter Software

                      Comment

                      Working...