compare 2 text files in batch mode keeping only the differences on the right side

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JosephAT
    Visitor
    • Mar 2015
    • 4

    compare 2 text files in batch mode keeping only the differences on the right side

    Hello, I've used BC3 before but not from a command line \ scripting perspective. I'm having trouble creating a solution for the following criteria.

    via MS-DOS batch file, compare 2 text files with an identical file layout extracting the differences from the "right side" to a results text file of the same format. The resulting text file cannot be a report.

    Left side file = -1 version
    Right side file = current version of the file.

    I'm using a script with the following but it generates a report...
    text-report layout:interleaved options:display-mismatches output-to:%3 %1 %2

    .. I need just the right side differences.

    thanks in advance for the assist.

    JoeT
  • Aaron
    Team Scooter
    • Oct 2007
    • 16026

    #2
    Hello,

    To call the script from the command line (just to have the same setup, with 3 variables), I assume you are using something similar to?
    bcompare.exe "@c:\bcscript.txt" "c:\file1.txt" "c:\file2.txt" "c:\bcreport.xml"

    With your bcscript.txt file containing:
    text-report layout:xml output-to"%3" "%1" "%2"

    We do not have a report type from scripting which would only contain the right differences. This could be generated from the interface, using a combination of Toggles display filters, and then generating the report. Or you can use the XML layout, which can be parsed by an external/other script to pull out only the nodes you need. The other layout types could also be parsed to varying degrees.
    Aaron P Scooter Software

    Comment

    • JosephAT
      Visitor
      • Mar 2015
      • 4

      #3
      Thanks, that gets me pretty close. I've listed the DOS batch command and the script commands used to generate the resulting XML file. It includes only the differences and can be swept by an additional process for only the right side differences. This is handy when comparing two versions/generations of the same file and only want to target the "updates".

      MS-DOS Command:
      "C:\Program Files\Beyond Compare 3\BComp.exe" @BC_Script.txt /silent sorted_old.txt sorted_new.txt results.txt

      BC_Script.txt:
      text-report layout:xml options:display-mismatches output-to:%3 %1 %2

      Comment

      Working...