Exclude a directory without exculding file of the same name

I have a directory named “data”. I would like to exclude it from sync but I have other file or directories with are name “data”

How can I exclude /home/user/data but not /home/user/A/data?

https://docs.syncthing.net/users/ignoring.html does not cover this case it seems.

From the docs:

A pattern beginning with / matches in the current directory only. /foo matches foo but not subdir/foo .

1 Like

Also a slash at the end matched dirs not files regardless of folder root or not

1 Like

Is that really true? I think as we walk the file system, items don’t have trailing slashes?

Please note that directory patterns ending with a slash some/directory/ matches the content of the directory, but not the directory itself. If you want the pattern to match the directory and its content, make sure it does not have a / at the end of the pattern.

(Ignoring Files — Syncthing documentation)

Half true :slight_smile:

It matches the things under the directory, by way of being a prefix of those paths.

That said, it might make sense to have it match like imsodin suggested it should. We know at every instance whether the thing we are looking at is a directory, and could make it match a directory/ pattern. There is already another way to express “all sub-things of a directory but not the directory itself” (directory/**) so we wouldn’t lose that possibility, just gain the capability to say “match a directory name like this and any children”.

1 Like

Thanks, it covers my use indeed (sorry I have read too quickly the doc).

In the case the directory “backup” is inside a subfolder, is /subdir/foo works for excluding only subdir/foo ?

Yes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.