Announcement

Collapse
No announcement yet.

Comparing 2 text files in DOS-Box / command line

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

  • Comparing 2 text files in DOS-Box / command line

    Hello everybody

    I want to compare 2 text files in DOS-Box / command line. My files are really text files and have the extension DCM. For that I already created a new file format in Tools >> file formats:

    *.DCM
    [X] Trim trailing whitespace
    Grammar:
    Comment
    (X) Lines
    Text matching: ^\*[^\r\n]*
    [X] Regular expression
    [X] Insert spaces instead of tabs
    Tab stop: 4

    As I have read for comparing within batch jobs on command line I have to use bcomp.com . I am assuming that's right.
    I have tried that command line call, but it does not write _any_ file.
    bcomp.com /silent /closescript /qc /ro /iu /automerge /savetarget=bc-target.dcm /mergeoutput=bc-merge.dcm my_src.dcm ..\my_dest.dcm

    Has anybody some hints please?
    My goal is to get a file with the differences and if possible also an exit code like ERRORLEVEL under Windows.

    regards

  • #2
    Hello,

    BC4 requires a graphical environment option to run, so while it would run from the Windows command line, it would not run in a DOS only environment. For this testing, please try from the Windows Command Prompt.

    Also, for any troubleshooting, you should remove /silent, which suppresses all warnings or error dialogs. Several of your selected command line arguments do not support simultaneous execution: /qc is specific for two files, but wouldn't work with an /automerge, while /savetarget and /mergeoutput also are for separate tasks.

    To get an error level for the comparison, use:
    bcomp.com /qc "c:\file1" "c:\file2"

    to generate a report of the differences, you would need to use script as a separate call (which will not overlap with /qc):
    bcomp.exe "@c:\bcscript.txt" "c:\file1" "c:\file2" "c:\temp\bcreport.html"

    where bcscript.txt is:
    Code:
    text-report layout:side-by-side options:display-mismatches output-to:"%3" output-options:html-color "%1" "%2"
    Aaron P Scooter Software

    Comment


    • #3
      Hello Aaron,
      thanks so far. Would you please mind pointing me to the subpage of your website with de documentation about the script format?
      Thanks in advance, best regards

      Comment


      • #4
        Scripts: https://www.scootersoftware.com/v4he...l?scripts.html

        Scripting Reference: https://www.scootersoftware.com/v4he...reference.html
        Chris K Scooter Software

        Comment


        • #5
          Hello,
          as I want to understand you right, you wrote:
          BC4 requires a graphical environment option to run, so while it would run from the Windows command line, it would not run in a DOS only environment. For this testing, please try from the Windows Command Prompt.
          This means in reality, BC will _every time_ _open_ a graphical window?
          regards

          Comment


          • #6
            BC4 can run with /silent or /closescript to suppress the interface or close it after running, but it has to be run in an environment where the interface is possible. The first test is to call "bcompare.exe" by itself to make sure the program can run and launch, showing the main dialog. If it can, this location can also run scripting. This is more commonly a question for Linux, where the OS may be a Terminal with no graphical components. For Windows, Windows is almost always set up to allow a graphical interface. However, you mentioned DOS Box, which is a DOS environment and not the same as a Windows Command Line.

            I always suggest avoiding /silent until the script is up and running after some testing. /silent suppresses everything, including any warning dialogs or error messages, so it is extremely difficult to troubleshoot while it is in place.
            Aaron P Scooter Software

            Comment


            • #7
              Hello Aaron,
              thanks for your answer. So it's a case of missunderstanding or definition. Beg your pardon. I said "Box". So for me this is always a Box in another environment., I_meant_ in really a Windows command line and not a standalone DOS OS.
              Have a nice day. Thomas

              BTW: If I get it right my problems would probably also be solved with the diff command from UNIX/Linux, and it does it all (errorlevel/diff-file) in one call. And there are windows portations too.
              Code:
              diff -a -b -B --ignore-matching-lines=^\*[^\r\n]* --suppress-common-lines -t filein.dcm ..\filetarget.dcm >fileout.dcm

              Comment


              • #8
                Hello,

                Scripting a text-report using a patch layout is probably close to the output type you need. I would suggest generating this report type in the graphical interface first (and experimenting with different layouts). Once you find the best for your use case, you can then call to a script file that generates the same report and layout combination from the Windows Command Prompt.
                Aaron P Scooter Software

                Comment


                • #9
                  Great answer,
                  thanks Aaron. Have a nice day.

                  Comment

                  Working...
                  X