Announcement

Collapse
No announcement yet.

Comparing a large amount of files in a filter

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

  • Comparing a large amount of files in a filter

    So I am calling BC3 from the command line to open up a a comparison between my local source code to a "deployment folder" the problem is I only want to see the things that I have changed. I have written a tool that will tell me exactly what files I have changed for a given project based on my convention. I use that list of files to pass into the command line a "white list" of files in the filters parameter. It normally works fine for small amounts of files, however, if I have a lot of files changed in the project it barfs. I believe it is because there is a command line limitation on the number of characters that can exist in the actual command and I am surpassing it.

    So my question is, Can i use a text file or some other method (scripting) to specify the filter list that will support any number of files? I want to open a visible comparison between the local source control white listing only the files I have changed to an empty deployment folder (I do not want to automatically copy in case there are specific files i don't want to move for any reason).

  • #2
    I often use a vbScript and read the filenames to compare from text file. Here is some sample code. Create a file with a .vbs file extension, copy in the following code, then update the path names and the name of the file containing the list of files to compare. Be sure to use the appropriate BC3 path for your system (32-bit or 64-bit).

    Code:
     Option Explicit
    
     Const ForReading = 1
     Const ForWriting = 2
    
     Dim WSHShell, fso, oFolder, oFile, BC3, lResult
     Dim sLeftPath, sRightPath, sFileList, sFile, sMsg
    
     Set WSHShell = CreateObject("WScript.Shell")
     Set fso = CreateObject("Scripting.FileSystemObject")
     
     sLeftPath = "C:\LeftPath\"
     sRightPath = "C:\RightPath\"
     sFileList = "C:\FileList.txt"
    
     BC3 = """C:\Program Files\Beyond Compare 3\BComp.exe"" "          'For 32-bit Windows
     BC3 = """C:\Program Files (x86)\Beyond Compare 3\BComp.exe"" "    'For 64-bit Windows
    
     sMsg = ""
     If not fso.FolderExists(sLeftPath) Then sMsg = sMsg + "Folder not found: " + sLeftPath + vbCrLf
     If not fso.FolderExists(sRightPath) Then sMsg = sMsg + "Folder not found: " + sLeftPath + vbCrLf
     If sMsg = "" Then
        If fso.FileExists(sFileList) then
           Call Compare_File_List
        Else
           Call Compare_All_Files
        End If
     Else
        MsgBox sMsg + vbCrLf + "Compare Aborted."
     End If
     Set fso = Nothing
    
     Sub Compare_File_List
         Set oFile = fso.OpenTextFile(sFileList, ForReading)
         While not oFile.AtEndOfStream
             sFile = oFile.ReadLine
             If fso.FileExists(sLeftPath + sFile) And fso.FileExists(sRightPath + sFile) Then
                 lResult = WSHShell.Run(BC3 + "/quickcompare=binary " + + """" + sLeftPath + sFile + """ """ + sRightPath + sFile + """", 0, True)
                 If lResult > 1 And lResult  Then WSHShell.Run BC3 + """" + sLeftPath + sFile + """ """ + sRightPath + sFile + """"
             End If
         Wend
         oFile.Close
     End Sub
     
     Sub Compare_All_Files
         Set oFolder = fso.GetFolder(sLeftPath)
         For Each oFile In oFolder.Files
             sFile = oFile.Name
             If fso.FileExists(sRightPath + sFile) Then
                 lResult = WSHShell.Run(BC3 + "/quickcompare=binary " + + """" + sLeftPath + sFile + """ """ + sRightPath + sFile + """", 0, True)
                 If lResult > 1 And lResult  Then WSHShell.Run BC3 + """" + sLeftPath + sFile + """ """ + sRightPath + sFile + """"
             End If
         Next
         Set oFile = Nothing
         Set oFolder = Nothing
     End Sub
    BC v4.0.7 build 19761
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

    Comment


    • #3
      So if I understand correctly that vb script will compare individual files (probably all in new tabs), But what I am looking for is a folder compare of a directory with a filter setup so that it only shows my whitelist of files. This will allow me to create an archive of the files I changed in a new folder. I am thinking the best way to do it might be to use a script where I can set the filters based on my file list then mirror the list over to the archive. I then would just open the comparison and I can choose what to remove.

      Comment


      • #4
        Hello,

        There are two concepts to differentiate: a filtered Whitelist and Different Files. Beyond Compare is capable of detecting differences and different files on a variety of criteria. If you only need to determine and look at a list of changed files, you can simply set this in the Folder Compare Session Settings and use the Display Filters to view only changed files.

        However, if you need to view changed files from a specific sub-set of files (from a whitelist), then you would need to set the File Name filters to show only those files first. How are you generating or determining this list. Traditionally, this list would not need to change every time you loaded a session; if there is a list of all files you *could* change, you would set that once and then just look at the different ones each time you loaded the session. Or is this list variable, and if so, how are you keeping track of it?

        One possibility would be to save a Session, and then manually edit that session's XML information in the BCSessions.xml file to set the File Name Filter before loading the application.
        Aaron P Scooter Software

        Comment


        • #5
          Originally posted by gozza888 View Post
          But what I am looking for is a folder compare of a directory with a filter setup so that it only shows my whitelist of files.
          Yes, you are right. My script is a way to open a white list of file comparisons. As Aaron alluded to, a completely automated solution that launches from the command line would be complicated as it would require a behind-the-scenes edit of a session xml file.

          To filter to a white list of files from the GUI, however, is a piece of cake. Simply open a folder session in BC3, click on the File Filters button on the toolbar (looks like a pair of glasses), remove the *.* from the "Include files:" list box, then paste in the white list. If each filename is on a separate line, there is no need to specify the ";" delimiter between each file name. There shouldn't be a problem with the size of the filter... I've already tested with over 2,000 filenames in the file filter without an issue.
          BC v4.0.7 build 19761
          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

          Comment


          • #6
            Originally posted by Aaron View Post
            One possibility would be to save a Session, and then manually edit that session's XML information in the BCSessions.xml file to set the File Name Filter before loading the application.
            Aaron, this sounds like a good candidate for the infamous customer wish list. It would be useful to be able to specify a .txt from which to load the file filter when calling BC from the command line or via a script.
            BC v4.0.7 build 19761
            ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

            Comment


            • #7
              Originally posted by Aaron View Post
              How are you generating or determining this list. Traditionally, this list would not need to change every time you loaded a session; ... Or is this list variable, and if so, how are you keeping track of it?

              One possibility would be to save a Session, and then manually edit that session's XML information in the BCSessions.xml file to set the File Name Filter before loading the application.
              So I use Visual Studio for my development (c#) and TFS for my source control and i am associating checkins to work items. I have a very large set of files code files that I am maintaining which is why i am looking to filter the list to just those that i have changed. I have written a tool that will find all the files in the changesets and open a beyond compare session with those files in their base file structure compared to an empty folder location that I will move them to for deployment purposes. Right now I am just using command line but if I have a big project that had a ton of changes the command line method fails.

              The Session possibility could work and may not be all too difficult. Would it work if I already had beyond compare open when the process was run (BCSessions.xml changed) and it opened another tab? I guess that is something I can try out manually...

              Although I do second Michaels suggestion of adding to the wishlist because seeing a white list view of a directory with hundreds of files would be very useful.

              I am not sure if I am going to get time to try out the BCSessions.xml change tomorrow but if I do I will post how it works out.

              Comment


              • #8
                Hello,

                Do the other files in your large set change unless you change them? And if so, what can change about them (timestamp, size, specific text)? If it is a definable difference, we may be able to simply ignore that type of change, and then only display other changes (the ones you have made).

                Editing and .xml file while the program is open can be tricky, since the previous tab may still have access to that session, and if already opened there may re-save the older version over it or other unexpected behavior.
                Aaron P Scooter Software

                Comment


                • #9
                  Originally posted by Aaron View Post
                  Do the other files in your large set change unless you change them? And if so, what can change about them (timestamp, size, specific text)?
                  As a developer, I sometimes have need to look for specific items in source code that need to be addressed for a given project. It may be a technology refresh where every place a given control is used, the source code needs to be updated. It may be a new coding convention that needs to be rolled out. Whatever the case, there may be other changes in the two code bases I am comparing that are irrelevant to the task I'm working on. Standard filters are not helpful in these situations. I only want to work with the subset of the files that have the coding issue I am dealing with. By the comments in the original post, my guess is that this user has a similar need:

                  Originally posted by gozza888 View Post
                  I have written a tool that will tell me exactly what files I have changed for a given project based on my convention. I use that list of files to pass into the command line a "white list" of files in the filters parameter.
                  It seems obvious to me that the user wants to ignore some differences in the source code and target others. He's developed a process that identifies the scenario he is looking for and launches BC3 to work with that subset of files. Since I've been in similar situations, I agree that what he's asking for would be useful.

                  Originally posted by Aaron View Post
                  Editing and .xml file while the program is open can be tricky, since the previous tab may still have access to that session, and if already opened there may re-save the older version over it or other unexpected behavior.
                  I'm not sure that I understand what you're trying to say with this statement... so it may not be clear to the original poster either. I agree that a user-written tool to update the session XML is not an ideal solution. That is why I suggested providing the ability to pass in a large file filter via a text file when BC3 is called from a script. Usage might look something like this:
                  filter <file masks>
                  filter maskfile: <name of text file containing file masks>
                  filter cutoff: ([<|>](<timestamp>|#[days])|none)
                  filter attrib: ((+|-)<attrib set>|none)
                  filter size: ([<|>]#[KB|MB|GB|TB]|none)

                  Likewise, a command line switch could be added to do the same thing when BC3 is called from the command line:
                  /maskfile <filename>
                  Last edited by Michael Bulgrien; 20-Sep-2010, 09:58 PM.
                  BC v4.0.7 build 19761
                  ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                  Comment


                  • #10
                    Originally posted by Michael Bulgrien View Post

                    ...I suggested providing the ability to pass in a large file filter via a text file when BC3 is called from a script. Usage might look something like this:
                    filter <file masks>
                    filter maskfile: <name of text file containing file masks>
                    filter cutoff: ([<|>](<timestamp>|#[days])|none)
                    filter attrib: ((+|-)<attrib set>|none)
                    filter size: ([<|>]#[KB|MB|GB|TB]|none)

                    Likewise, a command line switch could be added to do the same thing when BC3 is called from the command line:
                    /maskfile <filename>
                    Bump...
                    I am interested in Team Scooter's thoughts on this enhancement idea...
                    BC v4.0.7 build 19761
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                    Comment


                    • #11
                      Thanks for the suggestion. I've added it as a Wishlist entry. Normally we try to bounce a few ideas around first and get back with some questions, but a couple of us have been out of the office. We'll try to get back to this thread in a bit with a couple of other ideas.
                      Aaron P Scooter Software

                      Comment

                      Working...
                      X