command line options for individual diff reports in html

General questions about using ExamDiff Pro, ideas for new features, bug reports, and usage tips.
Post Reply
genx
New Member
Posts: 2
Joined: Wed Oct 20, 2004 12:06 am

command line options for individual diff reports in html

Post by genx »

I would like to write a batch file which runs through subdirectories and outputs individual file differences to HTML format into a different directory.

In other words, compare directory1(and subdirectories) with directory2(and subdirectories) and output the differences of each file to a 3rd directory(and subdirectories).
The directory structures are the same and it is assumed that the files contained within those (sub)directories have same names.

Code: Select all


  directory1                 directory2
    |- subdir_1                 |- subdir_1
        |- file_1                   |- file_1
        |- ..                       |- ..     
        |- file_x                   |- file_x
    |-                          |-
    |- ...          <========>  |- ...
    |-                  |       |-
    |- subdir_x         |       |- subdir_x
        |- file_1       |           |- file_1
        |- ..           |           |- ..     
        |- file_x       |           |- file_x
                        |
                        |
                (output in html)    
                        |
                        |
                        \/
        directory3   
            |- subdir_1
                |- file_1.html
                |- ..    
                |- file_x.html
            |-
            |- ...
            |-
            |- subdir_x
                |- file_1.html
                |- ..    
                |- file_x.html





The diff reports are used in software upgrades to see what changes were made in the files (*.c and *.h)
I can get the output but all changes are logged to one file. I would like only files that have differences logged. I noticed as well that the HTML output is not always correct (“<” are picked up as tags) so the formatting of the HTML output is not quite accurate.

Hope u can help,
Thanx in advance, :P
Genx
User avatar
psguru
Site Admin
Posts: 2231
Joined: Sat May 15, 2004 4:23 pm
Location: California
Contact:

Post by psguru »

To achieve what you want, you need to write a script or a batch file.
For example, create 2 batch files:

diff.bat
========
for /R c:\directory1 %%F in (*.*) do call do_diff "%%F"

do_diff.bat
===========
set file1=%~1
set file2=%file1:c:\directory1=c:\directory2%
set file3=%file1:c:\directory1=c:\directory3%.html
C:\Tools\PrestoSoft\Pro\ExamDiff "%file1%" "%file2%" /o:"%file3%" /html /no

This assumes that c:\directory3 has the same directory tree structure as c:\directory1 and c:\directory2, but no files. If you want to create sub-folders in c:\directory3 dynamically, you need to extend do_diff.bat batch file to create such sub-folders by parsing %file3% variable.


As far as HTML reports treating “<” are as tags, I can't reproduce this problem (“<” and “>” are replaced by "<" and ">" respectively. If have an sample pair of files to illustrate this problem, please send both files to me privately.
Last edited by psguru on Thu Oct 21, 2004 5:19 am, edited 1 time in total.
psguru
PrestoSoft
genx
New Member
Posts: 2
Joined: Wed Oct 20, 2004 12:06 am

Post by genx »

hi,

Thanx for the info, I came up with a similar solution, but maybe not quite as elegant ;-)


Code: Select all


path = %path%;.;C:\Program Files\ExamDiff Pro;

set DIR1="C:\projects\directory1"
set DIR2="C:\projects\directory2"
set COPY_DIR="C:\projects\output_directory"

then for each sub directory, repeat the following step

-----------------------------

Code: Select all



cd subdir
md %COPY_DIR%\subdir

FOR %%f IN (*.h,*.c) DO ExamDiff %DIR1%\subdir\%%f %DIR2%\subdir\%%f /w /b /l /e /d /s /z  /r0 /no /o:%%f_diff.html /html

copy *.*_diff.html %COPY_DIR%\subdir

cd..

-----------------------------

this causes all subfolders to be recreated in the COPY_DIR directory, runs examdiff on all *.c & *.h files in the updated folder, outputs the HTML file with extension "_diff.html" and moves all the diff reports to the output directory

note


1. DIR1 - source parent directory 1(most update)
DIR2 - source parent directory 2(previous ver.)
COPY_DIR - destination parent directory of output HTML files
2. Batch file must be run from the DIR1 eg. ..projects\dir1\diff.bat




I'm quite sure that you could run a for loop across each subdir recursively and than call another batch file to do the comparison and moving of the files, but I had a maximum of 9 subdirectories so I chose the copy and paste way ;-)

About the HTML tags, I was using the switches incorrectly. Had the /f switch on. Apologies for my stupidity. ;-p

Thanx again for a superb & groovy program.

Genx
Post Reply