Announcement

Collapse
No announcement yet.

Ignoring unimportant differences using VBSCRIPTING

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

  • Ignoring unimportant differences using VBSCRIPTING

    Hello Everyone,

    I am new to using the softare beyond compare. We have 2 folders containing different files( viz notepads,.csv files etc). We need to compare the files of both the folders by ignoring umimportant differences like the date, timestap etc. using VBscripting.Is that possible? If not can anyone suggest any other alternatives to achive the same.

    Cheers!!

  • #2
    Hello,

    The first step would be to setup the Unimportance in the graphical interface, defining a File Format and grammar elements, then marking these elements as Unimportant. You can then update the Session Setting defaults to mark them as Unimportant by Default. We have details on this setup here:
    http://www.scootersoftware.com/suppo..._unimportantv3

    Next, you can then use BCScripting, which is run from the command line with: bcompare.exe "@c:\bcscript.txt"
    where bcscript.txt contains a series of commands, such as generating a folder-report or text-report of multiple files. What type of output would you like to generate? You can also generate the report first in the graphical interface, and once you know which one you want we can help with the script needed to generate it on the command line.
    Aaron P Scooter Software

    Comment


    • #3
      Hello Aaron,

      Thanks for the reply. We have to generate reports in 2 environmnts and just compare for the differences between those. We have to exclude the date and time stamps which typically appears in the first or second lines of the reports. So while making changes to the GUI settings how exactly do we set this in the Grammar tab. Are we using any regular exp to do this?
      We generate reports which compares two reports side byside and shows the difference in red as a html file. We jut need the date and time not to be shown in red. Can you help me design the BC scripting for this. ?

      Appreciate your help Aaron
      Cheers!

      Comment


      • #4
        Hello,

        We can help with scripting, but you will want to set up in the graphical interface first. This way the defaults can be properly set so the script can then use them.

        The link above includes directions and a video for help to define grammars. What style reports are you comparing? Are they Beyond Compare generated reports or another style? You would want to open a Text Compare session, load your two files, then follow the grammar steps to define the grammars, then mark that grammar as Unimportant in the Session Settings. By default, a grammar is Important, which is then can be toggled to be Unimportant (per session or as a new Default).

        Our trial is fully featured, so please feel free to fully test any workflow before any purchase is necessary.
        http://www.scootersoftware.com/download.php
        Aaron P Scooter Software

        Comment


        • #5
          Ignoring unimportant differences using VBSCRIPTING

          Hello Aaron,

          We are using text files which are situated in 2 different folders and comparing each report one to one. So i tried to set up the grammar tab following the video .
          For some reasons after i refresh the "Reload" tab in the beyond compare i am unable to see the changes. The date and timestamps are still showing as red. I have used the following text matching pattern as per the video(\d+/\d+/\d+\s\d+:\d+:\d+\s[AP]M) for time stamp and [0-9]{1,2}[a-z][a-z] [A-Z][a-z]* 20[0-9][0-9] for a date stamp( 12-Dec-2014) .Correct me if i am wrong in setting this up.
          After this what is the script to run the newly created log files. How to create that and how to execute that?

          Regards
          kprasad

          Comment


          • #6
            The pattern in the video is specific to a text pattern for dates. Is your "timestamp" in your text file setup as "10/10/1999 10:10:AM" with a single space between? If not, this pattern would not necessarily match any date string.

            The other RegEx you have defined: [0-9]{1,2}[a-z][a-z] [A-Z][a-z]* 20[0-9][0-9]
            does not appear to include '-' characters, so it wouldn't match on your provided 12-Dec-2014 sample. Is your month always 3 characters long? If so you could use:
            \d+-\w{3}-20\d+

            You will want to work with the graphical interface to test your Regular Expressions. Since scripting runs automatically, it can offer no feedback on your definitions and would be difficult to troubleshoot if you have correct or incorrect Regular Expression syntax. Regular Expressions can be tricky to define and require a bit of practice. Once you have them defined you can then work on the automation.

            My suggestion for the automation is to have it where:
            If you load a blank, new Text Compare, then drag and drop your two report files, your default settings are configured to automatically ignore the text you need to ignore.

            The script can then be:
            bcompare "@c:\bcscript.txt"

            where bcscript.txt is
            text-report layout:side-by-side options:display-mismatches output-to:"c:\bcreport.html" output-options:html-color "c:\YourFile1.txt" "c:\YourFile2.txt"
            Aaron P Scooter Software

            Comment


            • #7
              Hello Aaron,

              The date stamp on my report looks like 23-Feb-2015 and on the next line right underneth that we have the time stamp as 09:28am. So what would be regular expression to deal with this?

              Also do i just save the text-report layout:side-by-side options:display-mismatches output-to:"c:\bcreport.html" output-options:html-color "c:\YourFile1.txt" "c:\YourFile2.txt" in a notepad and save that as bcscript.txt.

              then from the command prompt we enter bcompare "@c:\bcscript.txt" to execute the script.

              Thanks for your immense help Aaron!!

              Cheers
              Kprasad

              Comment


              • #8
                The grammar would need to be per line, so you could have a Date grammar such as:
                \d+-\w{3}-20\d+
                and a timestamp grammar such as:
                \d+:\d+[ap]m

                And yes, you save the script command into a text file, which can have any name, you then call BC4 in scripting mode using the "@" to point to the script.txt file.
                Aaron P Scooter Software

                Comment


                • #9
                  thanks Aaron. that has worked!! however now we have another small issue. When i am ignoring the date and timestamp that appears at the header it also ignores other date and time stamp within the body of the report that we don't want to ignore. Are there any regular expression to just ignore the date and time stamp that appears at the headers of the reports( possibly within the first 2 lines maybe) but doesn't ignore the same anywhere else in the body of the report?
                  Below are the regular expressions that are working here for our reports:

                  Date stamp \d+-\w{3}-20\d+
                  Timestamp1 \d{2}:\d{2}:\d{2}[aA|pP][mM] ( this is for the reports that has time in format of HH:MM:SS)
                  Timestamp 2 \d{2}:\d{2}[aA|pP][mM] ( this is for the reports that has time in format of HH:MM)

                  Thanks
                  kprasad

                  Comment


                  • #10
                    You would need to define a longer RegEx that is unique to the format used in the Header, or use the Lines grammar item to match on a larger part of the Header (making that whole part of the Header Unimportant). The Lines grammar can match on a RegEx or just start at Line 1.
                    Aaron P Scooter Software

                    Comment


                    • #11
                      Thanks Aaron,

                      Just for info: Isn't it possible to automate the GUI settings programatically using QTP. I mean setting up the Grammer and file format. If not is there a specific reasons. Beyond Compare is built on Delphi and i have tried to use the Delphi addin but it doesn't identify the objects properly. Is there a specific reason why it doesn't identify the objects using QTP?

                      Comment


                      • #12
                        Hello,

                        No specific reason, but I do not believe we've tested against QTP. Grammars and File Formats are normally items you would set up once, then configure different sessions to use them. Do you have a couple variants you would need to toggle between? Or would a specific file mask work for the File Format file mask? Most default File Formats use a *.extension format, but this is expandable to match on more specific file names.

                        For full on the fly editing, I would usually recommend a Portable Install (which contains all BC Setting.xmls within it as a single directory). You can then use script to edit the XML directly to update settings, and then make a call to BC Scripting.
                        Aaron P Scooter Software

                        Comment


                        • #13
                          Hello Aaron,

                          The issue we are facing with this approach is that we have 2 folders- Which contains 1000s of reports that we are comparing against. So there are specific things that we may want to ignore in differet reports. So if we are setting up a set of regular expressions in one default session and invoke that everytime it might not ignore report specific things. On the other hand if we prepare Report specific default sessions with regular expression then we may need 1000s of default sessions which is not a feasable option in any case.

                          So i was hoping if you could suggest some ideas as to how to handle this situation?

                          Comment


                          • #14
                            Hello,

                            In this scenario, how much overlap would exist? If you have all of the different, specific grammars in one default format and session settings, would opening any one report then compare correctly? Or would some grammars need to be disabled for certain or most reports?

                            If you need to swap definitions on the fly, altering the .xml's directly with another scripting language previous to calling BC is probably the best solution. If you were using a graphical automation tool, the definitions would all have to exist, so you would have a 'master' .xml that already contains all definitions. In this scenario, you could comment out or generate the same .xml.
                            Aaron P Scooter Software

                            Comment

                            Working...
                            X