The support forum

Exclude/include pattern specification

Hooch :

Dec 17, 2014

Hello.
I would like to know exactly (100%) how pattern for includes/excludes works?

Is it exactly like in C#?

Nice thing would be to see live previews of patterns in that window where you select folders and files.

Alex Pankratov :

Dec 18, 2014



Perhaps it'd be the simplest to start with an example. Consider the following pattern:

        foo/bar*/*/file.e?e

It consists of 4 parts, split by the slashes (/) -

        foo
        bar*
        *
        file.e?e

For this pattern to match a file, each part needs to match a part of the file path. By default, only relative path from the configured location to the file is used for comparison. That is, if the source location is

        C:\Source

and the file is

        C:\Source\abc\xyz\file.ext

then the app will only be matching

        abc\xyz\file.ext

to the pattern.

The file path is split the same way as the pattern, at slashes. Then both sets of parts are compared *starting from the last part*. In the above case the first comparison will be between "file.e?e" and "file.ext".

If all parts *of the pattern* are matched, it's a match.

Since there might be more parts in the file path, this is referred to as a "tail match" pattern.

--

To require a complete match between the pattern and the relative file path, the pattern needs to start with ".\" (dot slash). For example,

        .\xyz\file.ext

will match

        C:\Source\xyz\file.ext

but not

        C:\Source\abc\xyz\file.ext

because the "abc" in latter won't have a matching part in the pattern.

This is a "complete relative match" pattern. In a sense, the leading .\ simply anchors the pattern to the top of the configured location.

--

If a pattern starts with a slash alone, it will be compared to the absolute path of a file. For example,

        \Source\abc\xyz\*.ext

will match

        C:\Source\abc\xyz\file.ext

but won't match

       C:\Source\Source\abc\xyz\file.ext

This is a "complete absolute match" pattern. It anchors the pattern to the root of the drive (or network share) of the configured location.

--

And, finally, there's a "complete match" form which includes either a drive letter or the \\server\share -

        X:\Source\abc\xyz\*.ext
        \\StorageBox\Space\Source\abc\xyz\*.ext

These are, obviously, the most specific anchors.

--

Apart from the slash, there are two more special symbols - the asterisk (*) and the question mark (?). These are your standard wildcards that work exactly as you'd expect - the asterisk matches zero or more symbols and the question mark matches exactly one symbol.

Do note that since both the pattern and file path are split first and compared second, the wildcards cannot be used to match slashes as they are removed during the splitting step.

--

... and that's about it. Is there anything I missed?

Hooch :

Dec 18, 2014

Thanks that was good read.
I would propose to add this description with some examples to application help.

If you have time it would be awesome to see your patterns working in real time in window where you select files/folders to include (Under "Then include the following items). Something like small icon next to folder/file showing if it is included/excluded by filter.

http://i.imgur.com/cT9okYf.png

Alex Pankratov :

Dec 22, 2014


Aye, noted.

This might not be an easy thing to implement *efficiently*, i.e. so that it won't lag on million-item trees, but let me see what I can do.

Hooch :

Jan 01, 2015

@Alex Pankratov.

My suggestion is to show it only on visible elements. It shouldn't lag that much or even at all than.

Alex Pankratov :

Jan 02, 2015

It won't work in all cases, e.g. if you start by excluding everything and then add "include *.exe" filter.

Hooch :

Feb 11, 2015

Hello. Small request. Can you add this topic to "FAQ / Features" Post before its gets lost? I think this is very helpful for new users.

Alex Pankratov :

Feb 12, 2015

Good idea. Done.

JohnO :

Jan 31, 2016

Might there possibly be a way around the "wildcards cannot be used to match slashes" in the future? It would be really great if it was possible to exclude e.g. all files with extension .xyz that are contained in directory abc/ and all subdirectories. Right now I have to do something like:
abc/*.xyz
abc/*/*.xyz
abc/*/*/*.xyz
abc/*/*/*/*.xyz
abc/*/*/*/*/*.xyz

Alex Pankratov :

Feb 01, 2016

Noted. The way to do this would be to add support for **, which in (some) Unix shells does exactly what you are asking for. Can't give you the timeframe, but this will be done at some point.

mtc :

Feb 23, 2016

Any chance of changing this topic heading to "Full pattern specification" instead of "Full patter specification"?   It's a worthwhile thread, and it'll be easier to find with the right spelling.

Alex Pankratov :

Feb 24, 2016

Good idea, done.

New topic

Create
Made by Pipemetrics in Switzerland
Support


Follow
Twitter
Dev blog
Miscellanea Press resources
Testimonials
On robocopy
Company
Imprint

Legal Terms
Privacy