This topic is interesting! Perhaps you, like me, find the FC command output format confusing and annoying, although it does provide the necessary information. The batch program below displays the result of the FC command and reorders it in such a way as to determine whether a new block of information has been added between the two lines of the source file or if the block of lines has been deleted from the source file, or in any other case the file has been changed (updated) . The hardest part is to choose a format for displaying information in a pleasant way, but I think my solution is pretty good!
@echo off rem FCOMP.BAT: Format FC output in a pleasant way rem Antonio Perez Ayala if "%~2" neq "" goto start echo Format FC output identifying added, deleted or updated sections echo/ echo FCOMP filename1 filename2 [/switches /for /FC /command] goto :EOF :start setlocal EnableDelayedExpansion set while=if not set do=goto endwhile set endwhile=goto while set "space= " set "spaces39= " fc %3 %4 %5 %6 %7 %8 %9 %1 %2 > differences.txt if %errorlevel% equ 1 call :FormatFC < differences.txt del differences.txt goto :EOF :FormatFC set /P line= set /P line= rem Process each set of differences :while %while% defined line %do% rem Load old and new sections of this set set line= set /P line= set old=0 :while1 %while% "!line:~0,5!" neq "*****" %do%1 set /A old+=1 set oldLine[%old%]=!line!%spaces39% set line= set /P line= %endwhile%1 :endwhile1 set line= set /P line= set new=0 :while2 %while% "!line:~0,5!" neq "*****" %do%2 set /A new+=1 set newLine[%new%]=!line!%space% set line= set /P line= %endwhile%2 :endwhile2 rem Identify the type of this set if %old% equ 2 ( echo ====== NEW SECTION ADDED ==================================================== echo/ echo(!oldLine[1]:~0,79! set /A new-=1 for /L %%i in (2,1,!new!) do echo( ^|!newLine[%%i]:~0,70! echo(!oldLine[2]:~0,79! ) else if %new% equ 2 ( echo OLD SECTION DELETED ========================================================== echo/ echo(---------!newLine[1]:~0,70! set /A old-=1 for /L %%i in (2,1,!old!) do echo -!oldLine[%%i]:~0,78! echo(---------!newLine[2]:~0,70! ) else ( rem both %old% and %new% gtr 2 echo ============================== SECTION UPDATED ============================== echo/ if %old% lss %new% ( for /L %%i in (1,1,%old%) do echo(!oldLine[%%i]:~0,39!^|!newLine[%%i]:~0,39! set /A old+=1 for /L %%i in (!old!,1,%new%) do echo(%spaces39%^|!newLine[%%i]:~0,39! ) else ( for /L %%i in (1,1,%new%) do echo(!oldLine[%%i]:~0,39!^|!newLine[%%i]:~0,39! set /A new+=1 for /L %%i in (!new!,1,%old%) do echo(!oldLine[%%i]:~0,39! ) ) rem Pass to next set of differences echo/ set /P line= set line= set /P line= %endwhile% :endwhile exit /B
Antonio
source share