When you compare files or folders, you can use filters to narrow the scope of the comparison. This can be useful when you want to simplify the comparison result by eliminating differences that you are not interested in. Filters are rules based on regular expressions. WinMerge uses the popular PCRE (Perl Compatible Regular Expressions) regular expression engine.
The basic function of filtering is simple: evaluate each item that would normally be compared (a folder, file, or line within a file), and if the filter expression matches the target item, apply the filter. Depending on the type of filter, the item is either included or excluded in the comparison.
There are different WinMerge filters for folder compare and file compare operations:
You can specify files to include in a folder comparison by using simple file masks, or, for more complex filtering, by applying multiple rules specified in a file filter.
Files and folders that are filtered are hidden in the result by default, which is typically what you want. You can click
→ to unhide filtered items, but the Folder Compare window shows only minimal information about them. For example, you cannot tell whether a skipped file is a text file or binary.Line filters are applied only to file compare operations. They let you ignore single line differences.
Substitution filters are applied only to file compare operations. They replace the strings in the diff block with the specified strings, compare them, and ignore the diff block if the replacement results match. They are useful for ignoring large numbers of uninteresting changes.
You can use one or more file masks that specify file extensions to include in a folder comparison. All other files are omitted from your selection.
Define and apply a file mask at the time you launch your folder compare operation:
If you are using the Select Files or Folders dialog, after choosing the 1st and 2nd folders, enter one or more file masks in the Filter field. The masks are applied when you start the folder compare operation.
If you are using the WinMerge command line, use the
-f
flag to specify file masks (see the example in the
next section).
You can specify file masks and extended filters using this format:
Filter1 of Group1
;Filter2
...|Filter1 of Group2
;Filter2
...|...
The |
character separates filter groups and acts as a logical AND.
Filters within the same group are separated by ;
and are interpreted with a logical OR.
A file is included only if it matches at least one filter in each group.
To include a literal |
(pipe) character in a regular expression that is not enclosed in double quotes (such as in f:
or f!:
filters), use ||
instead.
Example: f:(abc||def)\.txt$
Each filter (e.g., Filter1, Filter2) can be one of the following types:
*.ext
File mask by extension (e.g., *.txt)
*.
Files with no extension (e.g., README)
*.ext
Exclude files matching the extension (Available since 2.16.19)
folder
\Target folders (must end with \) (Available since 2.16.19)
folder
\Exclude matching folders (Available since 2.16.19)
regexp
Match file names using regular expressions (Available since 2.16.49)
regexp
Exclude files matching regex (Available since 2.16.49)
regexp
Match folder names using regex (Available since 2.16.49)
regexp
Exclude folders matching regex (Available since 2.16.49)
expr
Filter expression for files (e.g. fe:Size < 1KB) (Available since 2.16.49)
expr
Filter expression to exclude files (Available since 2.16.49)
expr
Filter expression for folders (Available since 2.16.49)
expr
Filter expression to exclude folders (Available since 2.16.49)
file filter name
Apply a file filter by name (Available since 2.16.49)
Example 1. File mask
In this command-line example, the folder compare operation
includes only files with xml
or
txt
extensions. All other files are omitted:
WinMergeU c:\project\docs c:\temp /f
*.xml;*.txt
Example 2. Excluding folders (since version 2.16.19)
In this command-line example, the folder compare operation
excludes .git
and
.vs
folders:
WinMergeU c:\project\docs c:\temp /f
!.git\;!.vs\
Example 3. Filter expression (since version 2.16.49)
In this command-line example, the folder compare operation
includes only files with cpp
or h
extensions and
a file size less than 1KB:
WinMergeU c:\project\docs c:\temp /f
"*.cpp;*.h|fe:Size < 1KB"
WinMerge allows powerful filtering using expressions that operate on file metadata, contents, and comparison context. This section describes the supported attributes, operators, functions, data types, and evaluation rules.
Supported literal types include:
Boolean: true
, false
Integer: 64-bit signed integers (e.g., 1024
, or with units like 100KB
, 7days
)
String: Enclosed in double quotes (e.g., "example"
)
Internally, values may be of the following types:
Boolean, Integer, Timestamp, String, File Content, Array, or undefined
.
Filter expressions support a variety of attributes referring to file metadata and content. Attribute names are case-insensitive. You can optionally specify which side of the comparison (Left, Right, or Middle) an attribute applies to by using a prefix.
Returns true
if the file exists, false
otherwise
File name
File extension
Returns the relative path excluding the file name and base folder
Returns the full path of the file
File size
Last modified timestamp
Last modified date string in yyyy-MM-dd
format
Creation date timestamp
Returns the file attributes as an integer value
Returns file attribute string. Examples:
"R"
for Read-only,
"H"
for Hidden,
"A"
for Archive,
"S"
for System file.
Content of the file. Returns a FileContent-type value. Only contains
and recontains
can be used with this type.
Prefixes may be added to specify the comparison side:
Left: Applies to the file on the left side (e.g., LeftSize
)
Right: Applies to the file on the right side (e.g., RightDate
)
Middle: Applies to the middle file in 3-way comparison (e.g., MiddleName
)
Attributes without a prefix (e.g., Size
) return an array of values from all available sides (Left, Middle, Right).
Attributes without a side prefix (e.g., Size
) return an array of values from all available sides
(Left, Middle, Right). When applying an operator to such arrays, behavior differs depending on whether the comparison is
with a scalar or another array.
When comparing an array to a scalar, the operation is applied to each array element individually.
This results in a boolean array. If any element in this boolean array is true
,
the overall expression evaluates to true
. Otherwise, it evaluates to false
.
When comparing two arrays, the behavior depends on the operator:
For =
and !=
:
The arrays must have the same length.
The result is a single boolean value, not an array.
=
returns true
only if all elements are equal.
!=
returns true
if any element differs.
For all other operators (e.g., >
, <
):
the operation is applied element-wise, producing a boolean array.
The final result of the expression is true
if any element in the boolean array is true
,
and false
if all elements are false
.
Example 5. Examples
[2, 4] = [2, 4] -> true
[2, 4] != [2, 5] -> true (because 4 != 5)
[3, 5, 8] > [6, 4, 2] -> [false, true, true] -> true (because at least one comparison is true)
Array vs scalar comparisons produce a boolean array.
The overall expression result is true
if at least one element is true
.
Array vs array with =
or !=
returns a single boolean value.
Array vs array with other operators produces a boolean array.
The final result is true
if any element is true
.
All string comparison operators (such as =
, !=
, like
, matches
, contains
, and recontains
) are currently case-insensitive.
<
, <=
, >
, >=
Numeric, timestamp, or string comparison
=
Equality comparison
!=
Inequality comparison
+
, -
, *
, /
, %
Arithmetic operators. +
and -
perform addition and subtraction. *
and /
perform multiplication and division. %
is the modulo operator (remainder).
and
, or
, not
Logical operators
like
Wildcard string match
You can also use not like
to perform the inverse match.
matches
Matches regular expressions
You can also use not matches
to perform the inverse match.
contains
Checks if a string contains a substring
You can also use not contains
to check for absence of the substring.
recontains
Checks if any substring matches a regular expression
You can also use not recontains
to ensure no match exists.
content
)Returns the number of lines in the file content or file content array as an Integer
. If content
is an array, the result is an integer array. Example: lineCount(Content)
content
, start
, count
)
Extracts the specified number of lines starting from the given line index in the file content or file content array, and returns them as a single concatenated string.
If content
is an array, the result is an array of strings.
source
)Returns the length of the string as an Integer
. If source
is a string array, the result is an integer array. Example: strlen(Name)
source
, start
, count
)Returns a specific range of text from the string or string array as a String
. If source
is a string array, the result is a string array. Example: substr(Name, 0, 3)
Returns the current date and time as a Timestamp
value.
Returns today's date as a Timestamp
value representing 00:00:00.000
at the start of the day.
timestamp
)Returns the first day of the week, which is always Sunday regardless of locale.
timestamp
)Returns the first day of the month.
timestamp
)Returns the first day of the year.
value
)Returns the absolute value of the integer or integer array. If value
is an integer array, the result is an integer array.
booleans
)Returns true
if all elements in the boolean array satisfy the condition.
array
)Returns true
if all values in the array are equal.
File sizes support these suffixes:
KB, MB, GB, TBTime durations support these suffixes:
weeks, week, w, days, day, d, hours, hour, hr, h, minutes, minute, min, m, seconds, second, sec, s, milliseconds, millisecond, msec, msSize < 10KB
- Any side's size is less than 10KB
LeftSize >= 10MB
- Left side file is at least 10MB
allof(Size < 1MB)
- All sides are under 1MB
abs(LeftSize - RightSize) < 1KB
- Size difference is small
DateStr = "2025-07-20"
- File was last modified on that date
Date >= today()
- Modified today or later
AttrStr contains "R"
- File is read-only
Name matches "file[0-9]\.txt"
- Regex on filename
Content contains "Test"
- File content includes keyword
sublines(Content, 0, 1) contains "XML"
- First line contains "XML"
(Extension = "log" and Size > 10MB) or (Date < today() - 7days)
- Large log files or files older than a week
AttrStr not contains "H" and Name like "*.tmp"
- Non-hidden temporary files
File filters are text files with an extension
of flt
. They enable you to apply multiple filtering
rules to a folder comparison. Unlike file masks, file filters can either
include or exclude matches.
WinMerge installs a number of predefined file filters. If
these file filters do not provide the filtering you need, you can create
your own. To make that task easier, WinMerge also provides a template file
named FileFilter.tmpl
. This section describes how to
apply file filters to comparisons, and documents the file filter syntax.
Using the Filters dialog describes how to add, edit, and manage
filters.
WinMerge automatically detects file filters in these locations:
This is where the predefined file filters are installed. For
example, C:\Program Files\WinMerge\Filters
. You
can create or copy filter files in this location to make them
available to all users on your system.
Before creating a new file filter, see if the predefined ones already contain what you need. If not, you might find useful rule examples in the existing files.
The location of this folder is defined in the System page of
WinMerge options. By default, it is specified as a subfolder in your
user profile folder (for example, Documents
in
Windows 10). Filters that are created or copied here are normally
visible only to you. If you create new file filters, you can copy
them here to keep them private.
Before you can apply file filters that exist in any other folder, you must first install them.
You can apply a file filter using any of these methods:
When you launch a folder compare from the Select Files or Folders dialog:
After choosing the 1st and 2nd folders, click next to the Filter field.
In the Filters dialog, use the File Filters tab to choose a file filter and load it in the Filter field.
If a file filter is currently enabled, the selected file filter is already loaded in the Filter field.
Proceed with the compare operation. The file in the Filter field is applied when you start the operation.
To change file filtering after you have already launched a folder compare operation (for example, applying a different filter or disabling filtering):
Click
→ .In the Filters dialog, configure your new file filter setting, and click
.The new filtering is not automatically applied when you close the Filters dialog: press F5 to see the new results in the Folder Compare window.
When you launch a folder compare from the WinMerge
command line, use the -f
flag to specify a file
filter.
This section describes the syntax of WinMerge file filters and provides guidelines for writing them.
The comment delimiter is ##
. After a comment delimiter,
all characters in a line are ignored. WinMerge ignores most whitespace
characters in rules. However, a comment must always be preceded by one or
more whitespace (space or tab) characters. To use ##
as
characters in a rule, omit the whitespace prefix.
The first two required lines of a file filter are:
The filter name that is listed in the Files dialog
The type of filtering to be applied. Specify one of these values:
Includes everything except items matching the specified rule.
Excludes everything except items matching the specified rule.
When you choose the exclude method, you must also add a d (directory) rule that specifies the subfolders. It's usually a good idea to specify all subfolders, like this:
d: \\*$ ## Subfolders
Don't confuse these terms. Remember, in file filters, an include rule does not specify what to include, it specifies what not to include. Similarly, exclude does not specify what to exclude, it specifies what not to exclude.
Next, your file should contain one or more filter rules. You can add as many rules as you like. There must be one rule per line, and each rule must be entirely on one line (no line breaks are allowed in a rule). A rule begins with a type designator, followed by either a regular expression or a filter expression. The supported type designators are:
regexp
Match file names using regular expressions
regexp
Exclude files matching regex (Available since 2.16.19)
regexp
Match folder names using regex
regexp
Exclude folders matching regex (Available since 2.16.19)
expr
Filter expression for files (e.g. fe:Size < 1KB) (Available since 2.16.49)
expr
Filter expression to exclude files (Available since 2.16.49)
expr
Filter expression for folders (Available since 2.16.49)
expr
Filter expression to exclude folders (Available since 2.16.49)
Among the many regexp special characters, the following are particularly important in file filter rules:
Frequently required for rules to work correctly.
Frequently required for rules to work correctly. For example:
\.c$ ## matches only file names with the extension,c
. \.c ## matches any extension beginning withc
, likecpp
andcom
.
Forces special characters to match normal characters. For
example, to match a folder name, precede the folder backslash
delimiter with a backslash (\\
). To match the dot in a
file name, specify a backslash followed by a dot
(\.
).
No special characters or wildcards are used to match file names. To match all filenames of a certain type, simply omit the filename.
Rules are case-insensitive. For example, f: \.bat$
matches winmerge.bat
and
compare.BAT
.
Example 6. File filter rule examples
Some simple file filter rules:
f: \.cpp$ ## Match*.cpp
files f: \.h$ ## Match*.h
files f: ^My ## MatchMy*.*
files f: Dlg\. ## Match*Dlg.*
files d: \\test$ ## Matchtest
folders d: ^\\Build$ ## MatchBuild
folders d: Temp$ ## Match*Temp
folders (for example,FirstTemp
) d: Src ## Match*Src*
folders
Some rules with more complex regular expressions:
f: ^\.#.*$ ##.#filename.version
files f: Dlg\.c(pp)?$ ##*Dlg.c
and*Dlg.cpp
files f: ^I.*\.h$ ##I*.h
files f: Srv[1-9]\.def$ ##*Srv1.def
to*Srv9.def
files f: ^[h,k,m] ##h*.*
,k*.*
, andm*.*
files
In a file comparison, you can use line filters to ignore single lines. For example, you might use line filters to ignore comments or certain type of generated code, like version control system timestamps. Each line filter is a rule, and you can apply any number of line filters to a file comparison.
To learn how to add, edit, and manage filters, see Using the Filters dialog.
You can apply line filters using any of these methods:
When you launch a file compare from the Select Files or Folders dialog
After choosing the 1st and 2nd files, click next to the Filter field.
In the Filters dialog, use the Line Filters tab to enable the line filters you want to use (if any), or to see what line filters are currently enabled.
The Filter field does not indicate what line filters are enabled.
Proceed with the file compare operation. The enabled line filters are applied when you start the operation.
After you have already launched a file compare operation (for example, to apply different filters or disabling filtering)
Click
→ .Open the File Filters tab.
Check the individual line filters you want to apply, and uncheck filters that you don't want to apply.
You can also add, edit, and remove filters from the list by using the
, , and buttons.To turn on line filtering, check the Enable Line Filters. To turn line filtering off, uncheck the option.
Click
to dismiss the File Filters dialog.Click F5 to apply your changes and refresh the File Compare window.
A line filter is a rule that is evaluated against each single-line difference in your compared files, if line filter rules are enabled. When a rule matches a single-line difference, the difference is ignored.
Ignored differences are marked in the File Compare window with the Ignored Difference color (as defined in the Colors page of WinMerge Options). This enables you to distinguish ignored differences from other types. However, you cannot select or merge ignored difference.
Line filter matching can be described in terms of two ideas:
When a rule matches any part of the line, the entire difference is ignored. Therefore, you cannot filter just part of a line. For example, suppose two files have the following single-line difference:
File1:
# Jean Sibelius
File2:
# Janne Sibelius
With no filtering, the line is detected as a difference. But if
we apply a line filter rule with the expression, ^#
, the
lines are reported as identical, because the expression specifies only
the first character, which matches in both files.
A rule is applied to a multi-line difference only if all the lines match. For example, consider this two-line difference:
File1:
# Jean Sibelius # Pekka Himanen
File2:
# Janne Sibelius Pekka Himanen
The same ^#
rule matches the first line, but not
the second line. Therefore, the difference is not ignored.
It's usually good practice to use the beginning of line (
^
) and end of line ( $
) markers to
control your patterns precisely, because the rule is applied if any part
of a line matches the expression.
Example 7. Sample line filters
^MYTAG$
Filters lines that exactly match MYTAG
^::
Filters lines beginning with ::
^/\*.*\*/$
Filters lines beginning with
and ending with
/*
*/
^[1-5]00
Filters lines beginning with numbers 100, 200, 300, 400, and 500
Example 8. Line filter rule matching CVS Id lines
CVS Id lines look like this:
// $Id: Filters.xml 7591 2013-01-20 15:47:42Z christianlist $
... and can be filtered with this rule:
^// \WId: .*\$
Example 9. Filter line number comments in po files
po line number comments look like this:
#: src/filename.c:766
... and can be filtered with this rule:
^#
This section describes the Filters dialog, which provides functions to create and manage file filters and line filters.
To open the Filters dialog, use either of these methods:
In the Select Files or Folders dialog, click Filter field. You use this method when you want to apply a file filter to a folder compare operation.
to the right of theClick
→ . This method can be used at any time except when the Select Files or Folders dialog is open.The Filters dialog has a tab for each type of WinMerge filter:
Choose this tab to work with file filters for folder compare operations.
Choose this tab to work with line filters for file compare operations.
Choose this tab to work with substitution filters for file compare operations.
The main part of this tab is a list of file filters that are available for folder compare operations. The list includes shared, private, and installed file filters that WinMerge knows about, as described in File filter locations.
You must enable a file filter to make it available in a folder comparison operation, or to disable a current filter to stop it from being used:
Open the Filters dialog, if it is not already open.
Select a file filter or
from the list.Click
to dismiss the Filters dialog.There are several ways to apply file filters after enabling them. For details, see Applying file filters.
Use these buttons to manage your File Filters list and create new file filters:
Select a file filter in the list and click Testing file filter rules for details.
to quickly see how the filter works. SeeEnables you to locate a file filter and adds it to the Filters list. File filters that are not in either the shared or default private folder are not detected unless you install them.
Creates a new copy of a file template in either the shared or private filter folders, and opens it in your default editor. Edit the template and add your rules, as described in Creating a file filter.
Select a file filter in the list and click
to open the file in your default editor.Select a file filter in the list and click
to delete the file and remove it from the list. Yes, the file is really deleted!Your changes are saved when you click
to dismiss the Filters dialog. Line filters are stored in the Windows registry.If the file filters that are installed with WinMerge do not provide the filtering you need, you can create your own:
Click Filter field.
→ . Or, from the Select Files or Folders dialog, click to the right of theIn the Shared or Private Filter dialog, choose Shared Filter or Private Filter (see File filter locations for their uses) and click OK.
The Select Filename for New Filter dialog opens in the shared or private files folder on your system (if the private folder does not exist, WinMerge creates it).
In the Select Filename for New Filter dialog, enter a new file name and click
.Don't choose an existing file name: to edit an existing file, go back to Step 2 and click Edit instead of New.
WinMerge initializes the new file with the contents of the
FileFilter.tmpl
template, and opens it in your
default text editor.
Follow the template instructions to edit the template, updating the placeholder name and description and adding filter rules as described in File filter syntax. Save the file in your text editor.
If you want to quickly test a rule that you are defining, try clicking Test in the Filters dialog. See Testing file filter rules for details.
If you created your file filter in one of the standard
Filters
folders, and the Filters dialog does
not list your new file filter, try clicking
to close it, then click → again to reopen it. The
File Filters list should now include the new
file filter.
If you saved the file in an alternate location on your file system), WinMerge cannot detect it unless you install it. To make a file filter detectable anywhere on your system:
Click
in the Filters dialog.In the Locate Filter File to Install dialog, navigate to
the flt
file on your system, and click
. The File Filters list should now
include the installed file filter.
Use the Test Filter dialog to quickly test a file filter against sample data, to help you develop new rules or to understand how existing rules work. It can be easier than running a full compare operation.
Starting from the Filters dialog:
In the File Filters tab, choose the file filter you want to test.
If you want to see the rules you will be testing, click
now to open the file so that you can view it during the next steps.Click
.In the Test Filter dialog, choose the type of rule to test:
To test an f: file rule in your file filter, uncheck the Folder Name option.
To test a d: folder rule, check the Folder Name option.
Enter the text to test.
The text should be appropriate for the type of rule you are testing. For example, if you have checked the Folder Name option, you probably want to enter a folder name, such as \temp.
The Result box displays your entry,
followed by its status: either
passed
or
failed
.
Use this tab to configure and enable line filters for file compare operations. The tab features a list of rules. Each rule contains a single regular expression. You can apply any combination of rules from the list to a file comparison.
Below the Regular Expressions list is an edit box and buttons that you can use to maintain the list at any time by adding, editing, and removing rules.
To add a new rule:
Click
. Your edit cursor is automatically enabled in the edit box.Enter an expression in the edit box below the Regular Expressions list.
Click
to load the expression in a new line in the list.To edit an existing rule:
Select the line and click
.Edit the expression in the edit box.
Click
when you're done.To delete an existing rule, select (check) the rule and click
.In the Regular Expressions list, check just the filters that you want to apply, and uncheck any filters you do not want to apply.
Check or uncheck the Enable Line Filters option. If you turn filtering on, all the rules that are currently checked in the Regular Expression list are used. If filtering is off, no rules are used even if they are checked.
Click
to dismiss the Filters dialog and save your settings.There are several ways to apply file filters after enabling them. For details, see Applying line filters.
Regular expressions can be very complex. Fortunately, most file filters in WinMerge involve simple extension expressions, as shown in the examples in this topic. The filter files installed with WinMerge include many other useful examples.
Finally, there are lots of resources on the Web for help with regexps, including these sites: