5

I'm trying to use WinMerge to compare two directories:

C:\Users...\Desktop\Compare\35_A

C:\Users...\Desktop\Compare\35_HS

## This is a directory/file filter for WinMerge 
## This filter lets through only files ASP.NET developers care about 
name: ASP.NET Devel 
desc: Lets through only files ASP.NET developer cares about

## This is an exclusive filter 
## (it lets through only matching files) 
def: exclude 

## Filters for filenames begin with f: 
## Filters for directories begin with d: 
## (Inline comments begin with " ##" and extend to the end of the line) 

f: \.xml$ 
f: \.xlst$
f: \.xsl$
f: \.xslt$
f: \.dtd$ 
f: \.html$ 
f: \.htm$ 
f: \.css$ 
f: \.gif$ 
f: \.bmp$ 
f: \.jpg$ 
f: \.png$ 
f: \.js$ 
f: \.dll$ 
f: \.aspx$ 
f: \.asmx$ 
f: \.ascx$ 
f: \.vb$ 
f: \.resx$ 
f: \.cs$ 
f: \.js$ 
f: \.vbproj$ 
f: \.csproj$ 
f: \.sln$ 
f: \.webinfo$ 
f: \.config$ 

d: \\*$ ## Subdirectories 

def: exclude
d: \\bin
d: \\obj

The last 3 lines aren't part of the filter, I added those as I'm trying to ignore anything and everything in all \bin\ and \obj\ directories. I've tried both def: include and def: exclude, neither provides accurate results.

I've looked over the Help Documentation in WinMerge about the File Filters but I don't understand it.

sab669
  • 869
  • 6
  • 17
  • 30

4 Answers4

6

Include and exclude refer to what is shown in the list of files and folders after the comparison is made. The filters are including and excluding things from that list.

If you use an exclude filter, it excludes, from the file listing, everything not listed in the filter.

If you use an include filter, it includes, in the file listing, everything not listed in the filter.

In your case, you are using an exclude, so you are only going to see the files and folders that you specifically list in your filter. To block bin and obj folders, you would need to know the names of all of the other folders you might want to see, so they can be listed in your filter.

I find, for code, it's easier to use an include filter. That way, I can block out folders and files that I don't care about.

Change the first def: to be include, and remove the second def. I think you can only have one def. Your d: rules would then be

d: \\bin$
d: \\obj$
Patrick Seymour
  • 8,392
  • 31
  • 33
  • I would need to go and add an untold number of filters for all sorts of file types that are in there that I don't care about, if I can't use multiple `def:` statements. But I'll at least try that with the directories and see if that works. Honestly i think I might be easier just making a backup and manually search + delete those folders for now. – sab669 Jul 22 '15 at 14:37
  • I obviously don't know your folder structure and contents. I was just saying that I personally find includes easier for code. Your mileage may vary and often does. – Patrick Seymour Jul 23 '15 at 11:35
  • Fair enough. I'm just surprised that you can't use both include and exclude. Or at least two separate filters. There's just a bunch of text files, images, zips, and a handful of proprietary formats in there. – sab669 Jul 23 '15 at 11:39
1

I had some limited success with @heavyd's answer, but later found this is much easier in WinMerge's apparent successor WinMerge2011.

With WinMerge2011 I used

xd: \\bin(\\.+|)$
xd: \\obj\\

It can be differcult to find documentation, but I found http://forums.winmerge.org/viewtopic.php?f=4&t=1010

File/directory filters have been enhanced in WinMerge 2011 to allow for combining both inclusion and exclusion rules. Omitting the def: label in an .flt file makes f: and d: operate as inclusion rules unless prefixed with x, in which case they operate as exclusion rules. The f: and d: labels, again optionally prefixed with x to form an exclusion rule, can also be used with wildcard filters.

FYI WinMerge appears to no longer being developed. See overview notes in https://en.wikipedia.org/wiki/WinMerge. Download WinMerge2011 at https://bitbucket.org/jtuc/winmerge2011/downloads/

RockResolve
  • 109
  • 2
1

As others have mentioned, you can only have one def: line, and the filters actually peform the opposite action of the def: directive (ie when def is exclude filters actually include files).

So, with that knowledge, we can see that the following line is including all sub-directories.

d: \\*$ ## Subdirectories

I don't have WinMerge installed, and I'm not familiar with the RegEx engine in it, but you could try using a negative lookup to include all sub-directories except "bin" and "obj":

d: ^\\((?!bin|obj)(.+)|(.+)(?<!bin|obj))$
heavyd
  • 62,847
  • 18
  • 155
  • 177
0

The following expression properly excludes bin/obj folders and any subfolder.

d: ^(?:\\(?!bin\\|obj\\)[^\\\r\n]+)+(?<!\\bin|\\obj)$

It will include

\x
\x\y
\x\y\z
\binary
\cabin

but exclude

\bin
\x\bin
\bin\x
\x\bin\x
JBress
  • 1
  • 3