echo off

set wrk=c:\gmTestBed
dir %wrk%\*. /b > work.set

::-----------------------------------------------------------------
:: Cleanup prior reports/logs
::-----------------------------------------------------------------

if exist  RegTest.tab    del RegTest.tab   
if exist  Session.tab    del Session.tab   

if exist  AllLog.txt     del AllLog.txt    
if exist  BldLog.tab     del BldLog.tab    
if exist  Bundle.tab     del Bundle.tab    
if exist  BndScan.tab    del BndScan.tab    
if exist  LibHeaders.tab del LibHeaders.tab
if exist  LibProgIds.tab del LibProgIds.tab
if exist  MigSet.tab     del MigSet.tab    
if exist  MigStat.txt    del MigStat.txt   
if exist  SrcRef.tab     del SrcRef.tab    
if exist  SrcScan.tab    del SrcScan.tab   
if exist  SrcStruct.tab  del SrcStruct.tab 
if exist  TranLog.tab    del TranLog.tab   
if exist  TranAudit.tab  del TranAudit.tab   
if exist  gmProjects.tab del gmProjects.tab
if exist  SrcOrder.txt   del SrcOrder.txt
if exist  Metrics.htm    del Metrics.htm
         
::-----------------------------------------------------------------
:: append new reports into aggregate ones
::-----------------------------------------------------------------

for /f "tokens=1-4 delims=  " %%i in (work.set) do (
   echo.**********************************************************************************
   
   echo Gathering reports for [%wrk%\%%i\log]
   
   if exist "%wrk%\%%i\log\*.batch.tab"      findstr ".*" "%wrk%\%%i\log\*.batch.tab"      >> RegTest.tab  
   if exist "%wrk%\%%i\log\*.Session.tab"    findstr ".*" "%wrk%\%%i\log\*.Session.tab"    >> Session.tab  
   
   echo Gathering reports for [%wrk%\%%i\report]

   if exist "%wrk%\%%i\report\*-AllLog.txt"     findstr ".*" "%wrk%\%%i\report\*-AllLog.txt"       >> AllLog.txt
   if exist "%wrk%\%%i\report\*-Bldlog.tab"     findstr ".*" "%wrk%\%%i\report\*-BldLog.tab"       >> BldLog.tab   
   if exist "%wrk%\%%i\report\*-BndScan.tab"    findstr ".*" "%wrk%\%%i\report\*-BndScan.tab"      >> BndScan.tab  
   if exist "%wrk%\%%i\report\*-LibHeaders.tab" findstr ".*" "%wrk%\%%i\report\*-LibHeaders.tab"   >> LibHeaders.tab
   if exist "%wrk%\%%i\report\*-LibProgIds.tab" findstr ".*" "%wrk%\%%i\report\*-LibProgIds.tab"   >> LibProgIds.tab
   if exist "%wrk%\%%i\report\*-MigSet.tab"     findstr ".*" "%wrk%\%%i\report\*-MigSet.tab"       >> Migset.tab
   if exist "%wrk%\%%i\report\*-MigStat.txt"    findstr ".*" "%wrk%\%%i\report\*-MigStat.txt"      >> MigStat.txt
   if exist "%wrk%\%%i\report\*-SrcRef.tab"     findstr ".*" "%wrk%\%%i\report\*-SrcRef.tab"       >> SrcRef.tab   
   if exist "%wrk%\%%i\report\*-SrcScan.tab"    findstr ".*" "%wrk%\%%i\report\*-SrcScan.tab"      >> SrcScan.tab  
   if exist "%wrk%\%%i\report\*-SrcStruct.tab"  findstr ".*" "%wrk%\%%i\report\*-SrcStruct.tab"    >> SrcStruct.tab   
   if exist "%wrk%\%%i\report\*-TranLog.tab"    findstr ".*" "%wrk%\%%i\report\*-TranLog.tab"      >> TranLog.tab  
   if exist "%wrk%\%%i\report\*-TranAudit.tab"  findstr ".*" "%wrk%\%%i\report\*-TranAudit.tab"    >> TranAudit.tab  
   if exist "%wrk%\%%i\report\*gmProjects.tab"  findstr ".*" "%wrk%\%%i\report\*GMProjects.tab"    >> GMProjects.tab
   if exist "%wrk%\%%i\report\*-SrcOrder.txt"   findstr ".*" "%wrk%\%%i\report\*-SrcOrder.txt"     >> SrcOrder.txt
   if exist "%wrk%\%%i\report\*-Metrics.htm"    findstr ".*" "%wrk%\%%i\report\*-Metrics.htm"      >> Metrics.htm
)
dir *.tab *.txt *.htm
