[How to] Ignoring Custom Timestamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IbnSaeed
    Visitor
    • Dec 2007
    • 5

    [How to] Ignoring Custom Timestamp

    Hello

    I am trying to compare files but BC should only show those files which have had their contents changed/modified.

    I want to Ignore the time and date.

    Here is the sample Timestamp found among all the files:

    /*
    ************************************************** **************************
    *** ***
    *** My Script 7.3.4 ***
    *** File: index.php ***
    *** Built: Tue Apr 1 17:37:12 2008 ***
    *** http://www.domain.com ***
    *** ***
    ************************************************** **************************
    */

    How can I ignore the above timestamp in BC. I tried running it with "Compare Timestamps" unchecked but it still picks up some of the files where only the timestamp is different whereas the rest of the file is the same
  • Michael Bulgrien
    Carpal Tunnel
    • Oct 2007
    • 1772

    #2
    The "Compare timestamps" option in BC3 refers to the external file date/time stamp, not an internal date/time field within the text of the file as you've shown in your example. To ignore a content-based timestamp, you would need to create a grammar rule for the filetype you are comparing that will recognize the timestamp record and interpret it as unimportant text. You would need to do a rules-based compare in order for a folder session to recognize files that differ only by such a date/time field.
    BC v4.0.7 build 19761
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    Comment

    • IbnSaeed
      Visitor
      • Dec 2007
      • 5

      #3
      Originally posted by Michael Bulgrien
      The "Compare timestamps" option in BC3 refers to the external file date/time stamp, not an internal date/time field within the text of the file as you've shown in your example. To ignore a content-based timestamp, you would need to create a grammar rule for the filetype you are comparing that will recognize the timestamp record and interpret it as unimportant text. You would need to do a rules-based compare in order for a folder session to recognize files that differ only by such a date/time field.
      Thanks.

      Can you tell me how to create a grammar based rule. i dont have any experience with this.

      Comment

      • Michael Bulgrien
        Carpal Tunnel
        • Oct 2007
        • 1772

        #4
        In your example, it looks like the "timestamp" falls in a comment. So the easiest grammar rule would be to define a comment:

        Assuming BC3 doesn't support the file types you are using:
        1. Goto Tools \ File Formats
        2. Click New...
        3. Click OK for a new Text Format
        4. Give your new file format a name
        5. Specify a file mask such as: *.php
        6. Click on the Grammar tab
        7. Click New...
        8. Select element name: Comment
        9. Choose Category: Delimited
        10. In the Text from field, enter: /*
        11. In the to field, enter: */
        12. Click OK to save your grammer rule
        13. Compare your two files
        14. Enable the "" button in the BC3 toolbar to ignore unimportant differences

        Your internal "timestamp" will no longer show up as a difference simply because it is in a comment, and comments are by default unimportant.
        You can add other grammar elements (key words in the scripting language, for example). This will enable BC3 to color-code your syntax.
        BC v4.0.7 build 19761
        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

        Comment

        • maurice
          Enthusiast
          • Jan 2008
          • 42

          #5
          1. Tools Menu > Options > New or Clone an existing "rule" (more like set of rules).

          2. Open the new rule, click the "Importance" tab.
          3. In the upper section "Unimportant Text"
          - generally I check all the boxes except case
          - click "new"
          - select button for "Regular Expression"
          - build a rule to match any lines you want to ignore
          note: the asterisk "*" is an operator...you must use "\*" to match the character!

          for example:
          ^\*\*\*.*
          will match any line beginning with 3 *'s. "^" means at the start of the line; the last two characters; "." is a wild card, "*" is a multiplier meaning "0 or more of the preceeding character...here the wild card...so ".*" will ignore anything else to the end of the line.

          4. The other two lines would need two more "rules"...or one if you want to get fancy!
          Separate rules:
          a. ^/\*$
          b. ^\*/$

          This is a little hard even for me to read, but to break it down a bit:
          ^ = start of line
          / = first character; not a special character
          \* = asterisk, the character not the control symbol; requires "\" before "*"
          $ = end of the line

          The ^ and $ are not mandatory, but they prevent matching something else by mistake.

          These kind of rules can be a bit tricky, even if you know what you are doing.
          I think my example here will work, but if not, play around with it, or repost here and I'll try again.

          Another option is just to copy each line (or enough to make it unique) and paste into a rule beginning with "^".

          Comment

          • Michael Bulgrien
            Carpal Tunnel
            • Oct 2007
            • 1772

            #6
            With your new file format in place, you can right-click on a set of .php files in a folder compare and choose "Compare Contents..." from the context menu. Choose the option for a "Rules-based comparison". If the the only differences are unimportant changes (such as comments) then a "" will appear in the column between the the two files to indicate that, although the files are not exactly identical, there are no important differences to worry about.
            BC v4.0.7 build 19761
            ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

            Comment

            • Michael Bulgrien
              Carpal Tunnel
              • Oct 2007
              • 1772

              #7
              Sorry, just noticed that this post was in the BC2 section. My examples were written with the BC3 beta in mind. If you want full-screen edit capability and syntax coloring, try the BC3 beta.
              BC v4.0.7 build 19761
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              Comment

              • bconroy4
                Visitor
                • Feb 2012
                • 4

                #8
                Is there a way to incorporate ignoring internal file timestamps in a script?

                Comment

                • snidely.too
                  Expert
                  • Jul 2008
                  • 80

                  #9
                  Originally posted by bconroy4
                  Is there a way to incorporate ignoring internal file timestamps in a script?
                  I think that would involve loading a saved session that was configured in the GUI to use the appropriate rule and grammar item.

                  I think also that there's a tutorial on grammar rules in the knowledge base, but I haven't worried much about this for my own purposes.

                  /dps

                  Comment

                  • Aaron
                    Team Scooter
                    • Oct 2007
                    • 16002

                    #10
                    Hello,

                    Would this be in reference to BC2 or BC3? In both cases, the easiest method is to configure Rules or File Formats default behavior to ignore the text (timestamps, in this case) you wish to ignore.

                    The setup instructions are slightly different. In BC2, you can define unimportant text in the Tools menu -> Options, Rules section, select or create the rule for your file extension, Importance tab.
                    For BC3, you can find a more detailed guide here:
                    http://www.scootersoftware.com/suppo..._unimportantv3
                    Aaron P Scooter Software

                    Comment

                    • snidely.too
                      Expert
                      • Jul 2008
                      • 80

                      #11
                      Originally posted by Michael Bulgrien
                      Sorry, just noticed that this post was in the BC2 section. My examples were written with the BC3 beta in mind. If you want full-screen edit capability and syntax coloring, try the BC3 beta.
                      Shouldn't you be pointing to the production BC3? (look in
                      <http://www.scootersoftware.com/download.php>.)

                      The production BC3 is the version in your "sig", BTW, and IbnSaeed should be able to try it out using the trial period feature.

                      /dps

                      Comment

                      Working...