Filter certain files in base directory but not subfolders

Get help for specific problems
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

Hello everyone,

i got a problem that sounds simple but i don't know how to solve it. I'm using v8.1 and wanna stay with it.

Let's say I want to sync all folders and files from c:\desktop except .lnk files (shortcuts). If i exlude .lnk in the filterlist, every .lnk file in all subfolders get also filtered, but i only want to filter those files in a specific directory, without filtering those files in their subdirectories. This site couldn't help me:

https://freefilesync.org/manual.php?topic=exclude-items

"All *.tmp files located in SubFolder - \SubFolder\*.tmp"

Using the example above filters also all *.lnk files in the subfolders.
How can i filter only the .lnk files in the "drivers" folder when having a path like
c:\desktop\programs\drivers\new
without filtering the .lnk files from folder "new"? I also read something about using quotes but didn't help.

I tried to put this in the exclude list, deleting one then put next inside, not all together (desktop is the base folder), nothing worked:
programs\drivers\*.lnk
programs\drivers\"*.lnk"
"programs\drivers\*.lnk"

EDIT:
I want to add a second question. Let's say i want sync only .reg files from the folder c:\documents, excluding every other filetypes. When I filter everything with an asterisk (*) in the exlude list and add *.reg in the include list, it doesn't work because I assume the exlude list has priority. Like the manual says:

"Files and directories are only considered for synchronization if they pass all filter rules. They have to match at least one entry in the include list and none of the entries in the exclude list as presented in the filter configuration dialog"

Right now I write all filetypes in the exclude list except .reg files. If new filetypes appear in the directory, I have to add it to the exclude list every time or exclude items temporarily after comparing. It would be easier to make the include list the priority so for examples like this, you could exclude all files with * and include only the filetypes you want. Or am I missing a feature or easy way to exactly do that?
Posts: 292
Joined: 13 Apr 2017

Gianni1962

Let's say i want sync only .reg files from the folder c:\documents, excluding every other filetypes. When I filter everything with an asterisk (*) in the exlude list and add *.reg in the include list, it doesn't work because I assume the exlude list has priority. Like the manual says: filesyncfan3, 08 Jan 2018, 18:37
I will try to answer only to the quoted question:

Include: *.reg
Exclude: blank / empty
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

I will try to answer only to the quoted question:

Include: *.reg
Exclude: blank / empty Gianni1962, 09 Jan 2018, 00:46
Wow, that one was easy. I feel so dumb now. Till now i never understood the idea behind the include filter really. I thought it is to include exceptions of the exclude filter in a way that i never could figure out how it works. I thought the asterisk there is some kind of placeholder, but it has to be there because when you delete it and close the window, it comes back automatically. In fact, the include filter is active with only an asterisk although the checkmark is grayed out. I maybe tried to add a second line with *.reg under the first line with the asterisk, but of course it wouldnt work because all files would be included still because of the asterisk. I never tried to actually REPLACE the asterisk with anything because of all that didn't make sense to me. Thanks for the answer, this one is clear now :)

The first question seems trickier.
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

On your first/initial question:
Split your sync into two left-right folder pairs

- Folder pair 1 is essentially your present left-right pair.
For this pair you use your present (local) exclude filter for *.lnk-files.
This will sync everything except all *.lnk-files in programs\drivers\ and below.
- Folder pair 2 would need to refer to c:\desktop\programs\drivers and its right-side counterpart.
For this pair you use a (local) include filter *\*.lnk and an empty exclude filter.
This will include all *.lnk files in all subdirectories of programs\drivers\ , but not the ones in
programs\drivers\ itself, because of the backslash “\” part of the include filter.

You can define sync-setting (incl. filter) local to a specific left-right pair by using the icons in between the left- and right pair definition, as opposed to the global ones above the left-right pane.
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

@plerry

I have managed to do it for one folder subdirectory, but it wouldn't work the way I would like it to work. Let me explain with an easier example, because I think I can't follow you. Let's take the desktop for example. What I want is to sync everything on my desktop except the shortcuts (.lnk) on it. I want to sync all files and folders on the desktop and if the folders contain shortcuts, I want them to be synced too. Your example would contain two folder pairs with c:\desktop <-> d:\desktop like this?:

Pair 1: c:\desktop <-> d:\desktop ; include: * | exclude: *.lnk
Pair 2: c:\desktop <-> d:\desktop ; include: *\*.lnk | exclude:(empty)

That example didn't work, it would still sync the .lnk that are on the desktop. Now if I change Pair 2 to this:

Pair 2: c:\desktop\programs <-> d:\desktop\programs ; include: *\*.lnk | exclude:(empty)

it would work for the "programs" folder and all subdirectories of it, but not in other folders on the desktop.
Now with this example I would have to create a folder pair in FFS for each folder on the desktop and if I create new folders, I have to create new folder pairs again each time? That wouldn't be an option, I would rather copy all shortcuts then, it is not that huge of a problem to be honest, but it would be nice to know if FFS is able to do it. Or maybe it doesn't work because Im using v8.1. I don't want to try later versions because I had some small problems with the FFS database files when I came back to v8.1 after not liking versions above it.
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

Sorry, small mistake from my side:
In *\*.lnk , the first * is allowed to be empty, so *\ can/will also refer to the base directory.

Try changing your include filter in \*\*.lnk (adding a backslash in front of the previous *\*.lnk)
The first backslash now refers to the left and right base-folder,
and the next *\*.lnk should now only refer to all *.lnk-files in subdirectories (of arbitrary depth) of the base directory, but no longer to those in the base directory itself.
That is also in line with the \*\*.txt example in the manual-page.
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

Thanks alot! It worked indeed. Those questions I had till now are solved. Only now a new one came up. Nothing that I need to solve, but rather only would like to know why that is.

You said: "In *\*.lnk , the first * is allowed to be empty, so *\ can/will also refer to the base directory."

It makes sense, so the last example \*\*.txt means it filters any .txt files in any subdirectory (\*\) , I would assume.
Above this example on the manual page, the second last example says "All subdirectories of the base directories" - "*\" and it filters only the subdirectories like it says. But I would think it should be \*\ like the other example and if i actually write only \*\ into the filter, it works also like the *\, but why does the *\ work, when you said this before:
"In *\*.lnk , the first * is allowed to be empty, so *\ can/will also refer to the base directory."

So i would think *\ is pretty much the same as *?
Also I assume the filter phrases on the manual page are all that you need in FFS, there are no other that are not listed?
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

What you write about said second last manual-example makes sense and you might very well be right in that *\ should be referencing all (sub)directories, including the base directory.
However, it works as described in the manual.
So perhaps Zenju trapped that special case, as it would effectively render the sync useless as everything would then be excluded.

> So i would think *\ is pretty much the same as *?
See the part above. Next to that:
*\ refers to directories only, whereas * refers to directories and files.
So, it is a clear distinction.
Including (just) *\ only syncs the folder structure, not its content; * will sync everything
(for both: as far as not excluded via exclude-rules).
Excluding *\ (see above) syncs content of the base folder (as far as not excluded via other exclude-rules), not content in any of the subfolders; * will exclude everything.
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

So perhaps Zenju trapped that special case, as it would effectively render the sync useless as everything would then be excluded.
Which would be ok, since a layman like I am would probably assume exactly that. Since \*\ works exactly like that, I would use that in the manual. But if it's the case that the programmer programmed the filter phrases after his own undocumented logic, thats completely ok, as long the manual provides every filter phrase possible so everyone can come to a solution for a problem, even if one doesn't know exactly why it works like it works. Or maybe im just not intelligent enough. Now when I look at the manual, it does give the solutions to my problems, but it seems I needed a bit of help to make it clear for me.
Including (just) *\ only syncs the folder structure, not its content; * will sync everything
(for both: as far as not excluded via exclude-rules).
I can't confirm that. On v8.1 it syncs every subfolder and their subfolders with all the content/files. Just like \*\ does.
Let's say you have a folder called "Programs" on the desktop and want to sync only the "Program" folder (and maybe the subfolders) without the content/files.
The folder pair consists of "c:\desktop" and "d:\desktop".
Include: *\
Exclude: empty
But both sync the "Programs" folder with all subfolders and files. Really wondering now if it is possible at all to sync the folder structure alone without the content. On Windows 10 with v8.1 it seems not to be the case.
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

The old laptop I had available for testing when replying to your post is still running FFS v6.10 (which still functions perfectly fine for the purpose it is used for there ...).
In version 6.10 it performs as I described.
If that is different in v8.1, it must have changed somewhere in between versions,
the benefit of which is not instantly clear to me ...
Posts: 7
Joined: 7 Jan 2018

filesyncfan3

Thank you for clarifying.

Well, the benefit is clear to me when I think about it. Take my example above.
Just like excluding *\ syncs only the contents of the desktop and excludes ALL the subfolders and their contents,
including *\ should then include ALL the subfolders and their contents too, just like it does in v8.1 now. When I think about it now, it is easy to sync only the folderstructure from there on, because you can just sort the files by size after comparing and you get all folders in a row, you only need to mark everything except the folders and exclude it temporarily so you can only sync the folders. Needs a minute more, but i guess its nothing people need to do very often.

But in your version, if you want to sync only ALL the subfolders and ALL their content and not the desktop, the only way I can think about to do it, is to include everything (= no filters, respectively "Include:*") and exclude everything on the desktop temporarily after comparing, which you would have to do each time when you want to sync only the subfolders and their contents like I want.

Thats why v8.1 seems to be better suited for me, because manually excluding files temporarily from the desktop each time is exactly what I wanted to avoid, hence the "EDIT" question from my first post in this thread.
That's pretty much it. I have no questions left. Thank you alot for the help!