winmerge

How to apply a prediffer to WinMerge such that it runs on all files in the diff?


TL;DR: How can I automatically apply PrediffLineFilter on all diff results, not manually on only the open file?

WinMerge 2.16.4.0 supports using plugin prediffers to, among things, diff while ignoring items that meet conditions specified with a regular expression*. However it appears you must manually apply the prediff after you perform the diff (huh?) and on each and every individual file if it doesn't match a file filter. The help manual indicates the file filter for PrediffLineFilter.sct is *.txt and gives no guide to changing it.

I have thousands of files where the only difference might be a server name which follows a predictable pattern. (Example: server01, server02, etc.) I have figured out the regex for that pattern and the manual application of PrediffLineFilter after a diff works. But I can't be doing that on thousands of files.

How can I automatically apply PrediffLineFilter on all diff results, not manually on only the open file? I only want to see the files where the differences are meaningful.

*Learned this thanks to WinMerge : how to ignore specific words in a comparison?


Solution

  • In your winmerge installation folder, go to MergePlugins then edit the PrediffLineFilter.sct. Then change the return of get_PluginFileFilters to files you want this plugin to work on. For example you want this plugin to work on html and txt files:

    Function get_PluginFileFilters()
        get_PluginFileFilters = "\.html$;\.txt$"
    End Function
    

    After you have made these changes, select all the files on your folder compare window then right click > Plugin Settings > Prediffer Settings > Auto Prediffer, then refresh. Btw, in the later versions(2.16.10) you can do this in the Plugin Settings window.

    enter image description here