The exclude/ignore option is great - is there a "include only" option?

Hi all,

Just a little question.

There’s a device that I only wish to have certain types of files, in this case PDF’s.

Is there an option to “include only *.FILEEXTENSION”?

Thanks!

Chris

Yes, you only need to exclude first, and then ignore everything else after that.

In this specific case, I’d do something like this.

(?i)!*.pdf
(?d)*

Just remember that the order does matter. Just for the record, if you want to add more extensions, you could change the first line to (?i)!*.{pdf,doc,txt} and so on.

3 Likes

Thank you again @tomasz86 , you’re a wealth of knowledge. That’s just what I was looking for.

Very very much appreciated :+1:

Be slightly careful with this though. The “d” directive means “may be deleted if it prevents removing a directory” and is optimal for things like .DS_Store, thumbs.db, etc. Applying it to all files everywhere is … a bold move.

1 Like

To be honest, I’ve always used (?d)* in my patterns and never experienced any issues. I did have problems with folders not being deleted when I didn’t use it though. In what kind of situations could it be dangerous to use (?d)*?

Whenever the other side deletes a directory that you have files in that you want to keep.

Consider the patterns above. I have a directory with DoctoralThesisDraft.pdf and DoctoralThesisFinalAndOnly.doc and share it with another device. They get the directory and the PDF. They read my dissertation and then delete the directory with the PDF in it, since there is nothing else there. On my side, Syncthing deletes the PDF, the directory, and the pesky DoctoralThesisFinalAndOnly.doc that was in the way.

2 Likes

Thank you for that headsup calmh, very well explained. :+1: