Ignore patterns only for folders

(André De Santa Cruz) #1

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

0 Likes

(Simon) #2

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

(André De Santa Cruz) #3

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

0 Likes

(André De Santa Cruz) #4

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

0 Likes

(Simon) #5

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

1 Like

(Jakob Borg) #6

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.

0 Likes

(Simon) #7

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

(André De Santa Cruz) #8

@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.

0 Likes

(Jakob Borg) #9

However, the pattern foo will ignore foo completely.

0 Likes

(André De Santa Cruz) #10

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

0 Likes

(Jakob Borg) #11

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

(Simon) #12

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