Simple doubt on exclude filter

Get help for specific problems
Posts: 7
Joined: 19 Dec 2023

juma

I want to exclude any temporary MS Office file (also from subfolders).
I don't need to distinguish from file or folder.
Suppose the temporary file always begin with "~$".

I tested the following patterns:
~$* -> works only for files from root folder.
\~$* -> same as above.
*\~$* -> works for files from root and any subfolder.This is what I need.

I it true? Specially, "~$*" and "\~$*" are the same?

Cheers
User avatar
Posts: 2607
Joined: 22 Aug 2012

Plerry

Include and Exclude Filter rules are always relative to the left and right base location.
I believe that for that reason Zenju, the author of FFS, made the initial backslash "\" superfluous (but still allowed).
The fact that the initial backslash is still allowed makes it possible to define rules like your 3rd rule.
Because the initial wildcard "*" matches any arbitrary number of characters, including none, for the base directories your 3rd rule is identical to your 2nd rule.

(I have been excluding temporary MS Office files in this way for more than 10 years. See e.g. here.)
Posts: 7
Joined: 19 Dec 2023

juma

Now I found all the causes of my confusion:

1. "*" matches ANY character and this includes de folder separator.
2. The filter applies to the complete relative path.

Bang! I was not paying enough attention to the rules.

Thank you!
User avatar
Posts: 2607
Joined: 22 Aug 2012

Plerry

@Zenju
I think I am pretty proficient regarding FFS's filter rules.
However, triggered by the above thread I am partially back to my 2019 confusion.
In your reply to my confusion you state
So then we have *\ as a match for all folders, and with the previous rule, also all child elements. What is NOT matched however are child elements directly below the base folders. Base folders are just containers and have no representation in FFS that would be considered during filtering, so they are never matched.
(The underlining in the quote is mine).
I understand "child elements directly below the base folders" as being "files in the base folders themselves". Please correct me if I am wrong.

If *\ matches all folders, but not the files directly in the base folders and not the base folders themselves, how can *\~$* also be matching files directly in the base folders starting with "~$" ?
Does just *\ have a different meaning than the *\ in e.g. *\~$* ?

I really like to understand, and once I [finally ... ;-) ] do, may be able to (even?) better assist forum members.
User avatar
Site Admin
Posts: 7348
Joined: 9 Dec 2007

Zenju

"child elements" means files, folders, or symlinks.

If *\ matches all folders, but not the files directly in the base folders and not the base folders themselves, how can *\~$* also be matching files directly in the base folders starting with "~$" ?
Does just *\ have a different meaning than the *\ in e.g. *\~$* ? Plerry, 14 Mar 2025, 14:06
A path separator at the end like *\ has the special meaning to match folders only, just like *: has the special meaning to only match files, as documented: https://freefilesync.org/manual.php?topic=exclude-files

This rule does not apply to path separator in the middle like *\~$*:
* means zero or more characters, therefore this phrase defines a superset of \~$*, which is equivalent to ~$*.
User avatar
Posts: 2607
Joined: 22 Aug 2012

Plerry

@Zenju
Sorry for being so persistent, but now it seems there is a contradiction.
.
"child elements" means files, folders, or symlinks
I knew that as a general definition, but can/could not place that in the context as used.
So, I need to understand that "child elements directly below the base folders" means "files, folders and symlinks in the base folders themselves" alias "files, folders and symlinks in the root of the base folders", not just the files in the root of the base folders.
When I combine that with the last part of
So then we have *\ as a match for all folders, and with the previous rule, also all child elements. What is NOT matched however are child elements directly below the base folders.
this would imply that also folders (not just files) in the root of the base locations are NOT matched.

The contradiction rests in that (fortunately ...) this is not what FFS is actually doing.
When using the special meaning filter rule *\ , FFS actually matches all (sub)folders of the base folders, thereby also matching folders directly in the root of the base folders.
User avatar
Site Admin
Posts: 7348
Joined: 9 Dec 2007

Zenju

You're right, Plerry, in the quote you're citing I should have said "files/symlinks" instead of "child elements". I've edited the comment accordingly.
User avatar
Posts: 2607
Joined: 22 Aug 2012

Plerry

Thanks!
It only (...) took me 6 years to fully get it ... ;-)