The FFS manual has a page on Excluding items.
Although the Filter is probably most commonly used for Excluding (additional) items, the manual page does not state anywhere that the wildcard examples apply equally well to the Include Filter as to the Exclude Filter.
Although I consider myself pretty proficient regarding the FFS filter rules, I have a couple of (apparent) observations, remarks and ultimately questions.
• As an Exclude Filter rule, \FolderA\ and \FolderA\* seem to be equivalent.
Excluding FolderA automatically also excludes all of its content.
However, as an Include Filter rule, \FolderA\ and \FolderA\* seem to be different.
Including \FolderA\ will just include the folder, but not its content,
whereas including \FolderA\* will include all FolderA's content, and thereby also the folder itself.
I am not sure, when using an Include Filter \FolderA\*, and FolderA exists in the "source" location, but is empty, if still a FolderA is created in the "target" location (if it does not exist there yet).
• The manual page describes that the * (asterisk) character does stand for zero or more characters. The manual page also describes that *\ stands for all subdirectories of the base directories (implying it can not also stand for the base directory itself). However, as the * can stand for zero characters, it seems *\ could also stand for \ and thus also for the base directory. Conversely, all subdirectories of the base directories, but not the base directories themselves, would then need to be \*\ .
This becomes relevant when e.g. wanting to exclude everything not in the root of a base location. An exclude filter rule \*\* should work for sure, but according to the description in the manual it seems *\* would suffice, as the starting *\ (only) would stand for all subdirectories.
This however seems in contradiction with *\z* which, according to the manual, stands for all files (and folders) starting with the Z character (so, seemingly including those in the base directories).
Is the description for *\ incorrect? Or is (just) *\ an exception to the rule? If so, why? Anyway, it is confusing.
• When using multiple left-right folder pairs with local filter settings, the manual does not seem to provide info on which rules apply. I generally managed to avoid issues here, but it is interesting to know.
Are the local filter rules used instead of the global filter rules? This how it seems to be.
Or does a combination of global and local rules need to be met? If so, what exact combination?
Zenju, please correct me if/where I was wrong,
and address my questions at your earliest convenience
Include/Exclude Filter unclarities
- Posts: 2450
- Joined: 22 Aug 2012
- Site Admin
- Posts: 7210
- Joined: 9 Dec 2007
That would be a bug. Including "\FolderA\" should include all child elements as well. That doesn't logically follow from the filter syntax, but is a special rule that FFS applies, because it is what a user naturally expects (especially if entered as an exclude filter):However, as an Include Filter rule, \FolderA\ and \FolderA\* seem to be different.
Including \FolderA\ will just include the folder, but not its content,
whereas including \FolderA\* will include all FolderA's content, and thereby also the folder itself. Plerry, 10 Mar 2021, 16:01
A filter phrase is always extended to include child elements.
E.g. a phrase "bunny" matches both a file and a folder named "bunny". It is extended automatically as if you had added "bunny\*".
Sounds logical, however the base directory doesn't exist as an entity that is subject to the filter. The filter is applied only for the child elements of the base directories.• The manual page describes that the * (asterisk) character does stand for zero or more characters. The manual page also describes that *\ stands for all subdirectories of the base directories (implying it can not also stand for the base directory itself).
However, as the * can stand for zero characters, it seems *\ could also stand for \ and thus also for the base directory. Plerry, 10 Mar 2021, 16:01
As a corollary, a "/" filter matches nothing.
That's equivalent to *\, because the leading "/" is redundant. FFS always assume filter phrases relative to base dirs.Conversely, all subdirectories of the base directories, but not the base directories themselves, would then need to be \*\. Plerry, 10 Mar 2021, 16:01
That's right.This becomes relevant when e.g. wanting to exclude everything not in the root of a base location. An exclude filter rule \*\* should work for sure, but according to the description in the manual it seems *\* would suffice, Plerry, 10 Mar 2021, 16:01
... including all child elements as per the special rule mentioned previously.as the starting *\ (only) would stand for all subdirectories. Plerry, 10 Mar 2021, 16:01
That's right. The leading * can be empty, so the phrase includes "\z*", a.k.a files starting with z located in the base dir.with *\z* which, according to the manual, stands for all files (and folders) starting with the Z character (so, seemingly including those in the base directories). Plerry, 10 Mar 2021, 16:01
A file is included if it passes both global and local filters. So a local filter can be used for additional restrictions, but it cannot undo an exlusion by a global filter.When using multiple left-right folder pairs with local filter settings, the manual does not seem to provide info on which rules apply. I generally managed to avoid issues here, but it is interesting to know.
Are the local filter rules used instead of the global filter rules? This how it seems to be.
Or does a combination of global and local rules need to be met? If so, what exact combination? Plerry, 10 Mar 2021, 16:01
- Posts: 2
- Joined: 25 Mar 2021
I have a question regarding the last point:
The exclusion filter will override inclusion filters. So if I want to include only a specific subfolder of a parent folder, I need to exclude all subfolders explicitly, correct?
Example:
/parent
/parent/child1
/parent/child2
/parent/child3
/parent/child4
If I do
Include: * | /parent/child1
Exclude: /parent/
all subfolders will be excluded.
What's your proposed way of achieving this?
Include: /parent/child1
Exclude:
Do you have any plan to allow include filters to override exclude filters?
The exclusion filter will override inclusion filters. So if I want to include only a specific subfolder of a parent folder, I need to exclude all subfolders explicitly, correct?
Example:
/parent
/parent/child1
/parent/child2
/parent/child3
/parent/child4
If I do
Include: * | /parent/child1
Exclude: /parent/
all subfolders will be excluded.
What's your proposed way of achieving this?
Include: /parent/child1
Exclude:
Do you have any plan to allow include filters to override exclude filters?
- Posts: 2450
- Joined: 22 Aug 2012
The last point was about the combination of Global and Local Include and Exclude Filter rules, not just about the Include and Exclude Filter rules themselves.
Your question seems more generic.
There are different answers to your question, depending on what you mean exactly.
• If you only want to sync /parent/child1 (and nothing else) you can
1) create a more specific left-right base folder pair (specific down to child1), and use the default Include Filter * (=everything) and an empty (or possibly default) Exclude Filter.
OR
2) Leave you left-right base folder pair as is and put /parent/child1/* in your Include Filter (replacing the *) and use an empty (or possibly default) Exclude Filter.
• If you want to sync everything in your (present) left-right folder pair, except for the /parent folder, of which you only want to sync the /parent/child1 subfolder, you can
1) If there are only few and statically named subfolders of /parent, you can use a default Include Filter * and explicitly add all other subfolders of /parent than child1 (/parent/child2, /parent/child3, /parent/child4) to your Exclude Filter. However, this will still include any files in the root of /parent.
2) As per the Manual (Example: Exclude a sub folder except for certain files), you can define two left-right base pairs.
2a) Define two identical base folder pairs, both identical to your present left-right pair, use default Global Filter settings, and define Local Filter settings. For the first pair use a default Local Include Filter * and a Local Exclude Filter /parent or add this to the Local Exclude Filter. For the second pair use a Local Include Filter /parent/child1/* (instead of the default *), and an empty or the default Local Exclude Filter.
2b) Define your first left-right base folder pair identical to your present left-right pair, and use standard Global Include Filter * and add /parent/ to your Global Exclude Filter (and no Local Filter settings).
Define your second left-right base folder pair more specific, at least now down to /parent (and no Local Filter settings). As filter settings are relative to the left and right base location, the Global Exclude Filter rule /parent/ will not affect syncing your second pair.
Your question seems more generic.
There are different answers to your question, depending on what you mean exactly.
• If you only want to sync /parent/child1 (and nothing else) you can
1) create a more specific left-right base folder pair (specific down to child1), and use the default Include Filter * (=everything) and an empty (or possibly default) Exclude Filter.
OR
2) Leave you left-right base folder pair as is and put /parent/child1/* in your Include Filter (replacing the *) and use an empty (or possibly default) Exclude Filter.
• If you want to sync everything in your (present) left-right folder pair, except for the /parent folder, of which you only want to sync the /parent/child1 subfolder, you can
1) If there are only few and statically named subfolders of /parent, you can use a default Include Filter * and explicitly add all other subfolders of /parent than child1 (/parent/child2, /parent/child3, /parent/child4) to your Exclude Filter. However, this will still include any files in the root of /parent.
2) As per the Manual (Example: Exclude a sub folder except for certain files), you can define two left-right base pairs.
2a) Define two identical base folder pairs, both identical to your present left-right pair, use default Global Filter settings, and define Local Filter settings. For the first pair use a default Local Include Filter * and a Local Exclude Filter /parent or add this to the Local Exclude Filter. For the second pair use a Local Include Filter /parent/child1/* (instead of the default *), and an empty or the default Local Exclude Filter.
2b) Define your first left-right base folder pair identical to your present left-right pair, and use standard Global Include Filter * and add /parent/ to your Global Exclude Filter (and no Local Filter settings).
Define your second left-right base folder pair more specific, at least now down to /parent (and no Local Filter settings). As filter settings are relative to the left and right base location, the Global Exclude Filter rule /parent/ will not affect syncing your second pair.
- Posts: 4056
- Joined: 11 Jun 2019
Just remove the * and only include /parent/child1
- Posts: 2
- Joined: 25 Mar 2021
Yes, thanks, that's what I thought.Just remove the * and only include /parent/child1 xCSxXenon, 25 Mar 2021, 17:17
Lovely, that's amazing! I didn't know the part of multiple left/right pairs. Now I get what the global and local filters are about. Wow, that's versatile! Thanks for the detailed explanation.The last point was about the combination of Global and Local Include and Exclude Filter rules, not just about the Include and Exclude Filter rules themselves.
Your question seems more generic.... Plerry, 25 Mar 2021, 17:03