File: mergeall-products/unzipped/docetc/Tools/

Post-diffall file comparisons: a simple example of scraping filenames 
from's report, and a useful utility in general [3.3].

Automatically compare the files in all DIFFER lines in a 
final report, by running system commands to show detailed differences.
This is an alternative to manual copy/paste of the filenames in the 
diffall report's '[...] - [...]' lines.

Run this in the same folder where diffall ran, unless all paths absolute.
Pass one arg: the name of a file where's output has been saved.
This runs 'diff' commands on Unix and 'fc' commands on Windows for each 
DIFFER line; the output is these commands' output, separated by '=' lines.

See ../../UserGuide.html for license and attribution.

import sys, re, os

file = sys.argv[1]   # 1 arg = file with diffall's report section

differ = 'diff' if not sys.platform.startswith('win') else 'fc'

ndiffs = 0
for line in open(file, 'r'):
    match = re.match('^.*DIFFER.*\[(.*)\] - \[(.*)\].*$', line)
    if match:
        ndiffs += 1
        left, right =,
        print('\n\n', '='*80, sep='')
        print('[%s] - [%s]' % (left, right))
        os.system('%s %s %s' % (differ, left, right))

print('\nNumber diffs:', ndiffs)

[Home page] Books Code Blog Python Author Train Find ©M.Lutz