Ignore patterns only for folders

Is there a way to create a ignore pattern to work only on folders and not on files?

Put a slash ‘/’ at the end of your pattern, e.g. *foo*/. That will naturally also ignore any files within such directories, but it wouldn’t make sense to ignore a directory but not it’s children.

1 Like

May I suggest adding this information in the manpage? (https://docs.syncthing.net/users/ignoring.html)

This pattern will not ignore the directory though. It seems to ignore all children of the folder but not the folder itself.

Oh yea, right, forgot about that. Hmm, I don’t think there’s another solution to catch directories only.

1 Like

I’m not sure what this means - in order to have files, you need their containing directory to exist. For it to make sense I guess you mean that in a given directory foo you want to sync the files, but not any child directories? If so, I think something like this in the ignore patterns:

foo/*/**

would match all things in subdirectories of foo. You’d still get the directories inside of foo, but they’d be empty.

Ah that makes sense. I thought that in a big tree, they want to ignore all dirs matching *foo* but not files matching *foo* - however I struggle to see a use-case for this interpretation.

1 Like

@calmh I want to set a list of folders to not be considered when sync’ing. Imagine I have 3 folders at root: ‘foo’, ‘zoo’ and ‘joo’. I want only to sync folders ‘zoo’ and ‘joo’. I don’t want the folder ‘foo’ to be sync’ed in clients computers. Using the ignore pattern ‘foo/’ will only ignore files that are children of folder ‘foo’ but not the folder ‘foo’ itself. Clients that sync my root folder will have an empty folder ‘foo’ in their computers.

However, the pattern foo will ignore foo completely.

@calmh yes, but will ignore files named ‘foo’ too. I want to only ignore folders, not files.

That is not possible. But if, as you say, the folder is at the root, /foo will ignore it there and there only.

2 Likes

I do not mean this as a snide: This is exactly why you should explain your use-case up-front whenever asking for support. Both @calmh and I could have instantly told you the solution, but we both had a problem in our minds that wasn’t the problem you actually had :wink:

3 Likes

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