All files (but not folders)

Get help for specific problems
Posts: 1
Joined: 28 Sep 2025

Petibite

Hi,

I found this example but I can't apply to the following structure where I would like to exclude only files under the "Folder" but not under its subfolders. Could you help me out with it?
The \Folder\*: phrase also applies to subfolders which is unwanted by me at this case.
So, every files directly under \Folder\ should be filtered but not the subfolders and their files.

Example:
...
\Folder\file.txt
\Folder\file.exe
\Folder\file.dat
\Folder\file....
\Folder\Subfolder 1\...txt
\Folder\Subfolder 2\...txt
\Folder\Subfolder 3\...txt
Files and folders to be synced after the filter:
...
\Folder\Subfolder 1\...txt
\Folder\Subfolder 2\...txt
\Folder\Subfolder 3\...txt
User avatar
Posts: 2946
Joined: 22 Aug 2012

Plerry

If the subfolders of Folder are the only ones to be synced (i.e. no sister folders of Folder and their contents are to be synced) the solution is simple.
Then do not use an Exclude Filter rule, but replace the default Include Filter rule of * (=everything) by \*\* (=everything at least one folder level deeper than the left- and right base location).

Conversely, if sister folders of Folder and their contents are also to be synced:
• If the number of those sister folders is limited (and fixed), you can use the approach described above and add those distinct sister folders to the list of Include Filter rules. As in
\*\*
\SisterFolder1\*
\SisterFolder2\*
...
\SisterFolderN\*


• If the number of those sister folders is high and or dynamic, you can use the approach described in "Example: Complex filter rules with exceptions" on the page you linked.
Use two identical left-right folder pairs (equal to your present one), via the green + icon in front of your left-right folder pair). For your 1st left-right folder pair you use a local Exclude Filter (via the funnel-icon mid between each left-right pair) of \Folder\* , and for your 2nd left-right folder pair you use a local Include Filter rule \Folder\*\* .

Note that for Filter rules an asterisk (*) behind the last backslah (\) is often obselete.
User avatar
Site Admin
Posts: 7505
Joined: 9 Dec 2007

Zenju

\*\*
\SisterFolder1\*
\SisterFolder2\*
...
\SisterFolderN\*
Plerry, 28 Sep 2025, 12:08

This can be specified even shorter:
*\
\SisterFolder1\
\SisterFolder2\
...
\SisterFolderN\
User avatar
Posts: 2946
Joined: 22 Aug 2012

Plerry

For some reason the exception of just *\ (as opposed to using \*\ or \*\* ) does not "stick" for me, despite your explicit reply to that end.
Fortunately for me, my stubborn \*\ or even \*\* still works as intended ... ;-)

But I agree that, when assisting forum members, it is better to suggest the "official", most condense Filter rules.
User avatar
Site Admin
Posts: 7505
Joined: 9 Dec 2007

Zenju

For some reason the exception of just *\ (as opposed to using \*\ or \*\* ) does not "stick" for me Plerry, 01 Oct 2025, 09:45
That's strange. I've tested this syntax with the above example and it worked for me. No guarantees however if you're on an older FFS version.
The logic is that postfix "\" ensures only folders are matched, and then the following rule kicks in:
If the filter is matching a folder, all its files and subfolders are also (implicitly) matched. Thus the filter phrases SubFolder\ and SubFolder\* are synonymous.
https://freefilesync.org/manual.php?topic=exclude-files#:~:text=(implicitly)%20matched
User avatar
Posts: 2946
Joined: 22 Aug 2012

Plerry

You misunderstood my "does not stick for me".
It works exactly as you stated, also in my FFS version.
I myself am the "problem"; the exception does not readily stick in my mind.

Although you clearly stated it is an exception, I still find it confusing that in the case of just *\ an asterisk (*) has a slightly different meaning than in all other filter rules ...
That's why the exception does not readily stick in my mind ... :-(