Tapatalk

Command-line full folder compare to output only differences

Command-line full folder compare to output only differences

2
NewbieNewbie
2

    Sep 17, 2015#1

    Hello:

    I am investigating using UltraCompare as an automated reporting tool for auditing a code repository for compliance. To that end I'm utilizing UltraCompare's command-line functionality to run a folder comparison ignoring date/time differences, white space, line feeds, etc. However, I can't figure out how to get it to output only the differences. Is there a switch I'm missing somewhere for that? When I run the comparison through the interface with my filters in place, everything looks great. However, the text report generated at command-line doesn't appear to flag whether a file is considered the same or different, only whether it exists in both places. Then, a count of the totals I need is at the bottom. If I could get a file with only the differences that would be ideal, but having a flag per line that I can programmatically parse would be acceptable as well.

    Any help is appreciated!

    Thanks.

    6,685587
    Grand MasterGrand Master
    6,685587

      Sep 18, 2015#2

      First, the output format must be defined for the results file. This can't be done unfortunately via command line and can't be saved into a profile. Start UltraCompare, open Options - Configuration - Backup & Save and select Differences in context result which I think is the best for your task. Save this configuration and exit UltraCompare for Windows v15.10.

      From command line run:

      Code: Select all

      "%ProgramFiles(x86)\IDM Computer Solutions\UltraCompare\uc.com" -dms -lt -b -B -ne "C:\Temp\Test1" "C:\Temp\Test2" -o "C:\Temp\Results.txt"
      This produces for my example:

      Code: Select all

      [ 1 ] C:\Temp\Test1\ 18.09.2015, 07:05:58
      [ 2 ] C:\Temp\Test2\ 18.09.2015, 07:06:00
      -------------------------------------------------------------------------------------------------------------------------------
      | Name                         | Size    | Date                | Name                         | Size    | Date                |
      -------------------------------------------------------------------------------------------------------------------------------
      | ..\Test1                     | 307.182 | 18.09.2015 07:05:58 | ..\Test2                     | 305.153 | 18.09.2015 07:06:00 |
      | changes_different.txt        | 102.394 | 05.06.2015 19:10:00 | changes_different.txt        | 102.394 | 18.09.2015 07:07:38 |
      | changes_identical_binary.txt | 102.394 | 05.06.2015 19:10:00 | changes_identical_binary.txt | 102.394 | 05.06.2015 19:10:00 |
      | changes_identical_smart.txt  | 102.394 | 05.06.2015 19:10:00 | changes_identical_smart.txt  | 100.365 | 18.09.2015 07:07:28 |
      -------------------------------------------------------------------------------------------------------------------------------
      
       
      [ 1 ] C:\Temp\Test1\changes_different.txt 05.06.2015, 19:10:00
      [ 2 ] C:\Temp\Test2\changes_different.txt 18.09.2015, 07:07:38
      ------------------------------------------------------------------------------------------------------------------------
      +++ C:\Temp\Test1\changes_different.txt 05.06.2015 19:10:00
      --- C:\Temp\Test2\changes_different.txt 18.09.2015 07:07:38
      -----------
      @@ +2,7 -2,7 @@
      
      // History - Purged changes prior to v8.00
      
      + v22.10
      - v22.xx
        - Smarter indentation of auto-completed XML/HTML close tags
          * After closing tag is automatically inserted, press Enter
          * UE will reposition and properly indent the closing tag on the line beneath the new (active) line
      ------------------------------------------------------------------------------------------------------------------------
       
      Report type: All (Matching and Differences)
      
      Summary for 1 <--> 2:
      1981 Line(s) match   1 Block(s) diff   1 : 1 Line(s) diff
      
      ------------------------------------------------------------------------------------------------------------------------
      
      In first block the folder comparison is output, but as you wrote already without an indication if a file is being rated identical or different. I will look at this results output of the smart folder comparison more deeply on weekend and will send an appropriate enhancement request to IDM support by email when I can't find a setting to get a better output as I think, there should be also a column indicating the difference result for each file.

      Next the text comparison results are output to the results file for those files not being rated as identical according to smart folder comparison with the used options.

      Code: Select all

      @@ +2,7 -2,7 @@
      This line indicates the below 7 lines from first file and 7 lines from second file are written to the results file. The lines from first file are from line 2 (a blank line in my test case). The lines from second file are also starting from line 2. The different line from first line is output with a plus sign and a space at beginning of the line, the different line from second file with a hyphen and a space at beginning of the line. Identical lines are output as read from file. Note: Line 6 in compared files starts with 2 spaces and a hyphen. The differences in context result is problematic to interpret if there are lines in the files starting with plus or minus and a space.

      I tried also different output formats, but it looks like option -ne is only taken into account for a text comparison and not also for the text output of a smart folder comparison. I will send an enhancement request email to IDM support for taking also -ne, -m and -a into account for smart folder comparison with results written directly to an output file instead of displaying the results in UltraCompare.

      It would be of course possible to use a batch file which first finds out and reports which files exist only in one of the two folders and second runs with a simple for loop uc.com (or uc.exe) for text comparisons with appropriate options for the files existing in both folders with results file containing only different lines. This batch file would be of course a workaround for the lack of getting desired output directly from a smart folder comparison by UltraCompare.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Sep 18, 2015#3

        Hello Mofi:

        I appreciate your thorough reply. It is disappointing that UltraCompare doesn't have the same functionality at command-line as through the GUI. The software does everything I need as far as filtering, differences to ignore, and other preferences. I will investigate batching as an option.

        Thanks again.

        6,685587
        Grand MasterGrand Master
        6,685587

          Sep 27, 2015#4

          Hi andrewsc,

          I made today folder comparison tests from command line and detected an issue which is important for this topic, too.

          The command line in my previous post above contains just -dms for a smart folder comparison without -d and other options for the text comparisons as well as -ne for listing only not equal (different) files. But the output results file contains all file names independent on files being identical or different after smart comparison. So the parameter -ne is not really evaluated.

          But by using the command line

          Code: Select all

          "%ProgramFiles(x86)\IDM Computer Solutions\UltraCompare\uc.com" -d -dms -lt -b -B -ne "C:\Temp\Test1" "C:\Temp\Test2" -o "C:\Temp\Results.txt"
          with -d also being specified, the output file contains just

          Code: Select all

          [ 1 ] C:\Temp\Test1\ 18.09.2015, 07:05:58
          [ 2 ] C:\Temp\Test2\ 18.09.2015, 07:06:00
          -------------------------------------------------------------------------------------------------------------------------------
          | Name                         | Size    | Date                | Name                         | Size    | Date                |
          -------------------------------------------------------------------------------------------------------------------------------
          | ..\Test1                     | 307.182 | 18.09.2015 07:05:58 | ..\Test2                     | 305.153 | 18.09.2015 07:06:00 |
          | changes_different.txt        | 102.394 | 05.06.2015 19:10:00 | changes_different.txt        | 102.394 | 18.09.2015 07:07:38 |
          -------------------------------------------------------------------------------------------------------------------------------
          
           
          [ 1 ] C:\Temp\Test1\changes_different.txt 05.06.2015, 19:10:00
          [ 2 ] C:\Temp\Test2\changes_different.txt 18.09.2015, 07:07:38
          ------------------------------------------------------------------------------------------------------------------------
          +++ C:\Temp\Test1\changes_different.txt 05.06.2015 19:10:00
          --- C:\Temp\Test2\changes_different.txt 18.09.2015 07:07:38
          -----------
          @@ +2,7 -2,7 @@
          
          // History - Purged changes prior to v8.00
          
          + v22.10
          - v22.xx
            - Smarter indentation of auto-completed XML/HTML close tags
              * After closing tag is automatically inserted, press Enter
              * UE will reposition and properly indent the closing tag on the line beneath the new (active) line
          ------------------------------------------------------------------------------------------------------------------------
           
          Report type: All (Matching and Differences)
          
          Summary for 1 <--> 2:
          1981 Line(s) match   1 Block(s) diff   1 : 1 Line(s) diff
          Now the list at top contains just all folder names which always start with ..\ and the names of the files being different according to test compare with the specified text compare options.

          The order of the command line options is important. The option -d must be for UltraCompare for Windows v15.10 the first option. The order of the other options before the two directory paths does not matter.

          It would be also possible to use -m instead of -ne for getting listed only matching (identical) files.

          Using the default -a for listing all files is not really useful without an additional column indicating in text form which files are identical and which are different according to the text comparison executed on each file.

          Update: An additional character left to each folder/file name indicates since UltraCompare for Windows v2022.20.0.20 which files/folders are equal, different, exist only on left side or exist only on right side.
          Best regards from an UC/UE/UES for Windows user from Austria