I think I must be missing something here. I have a directory containing lots of sub-directories with all sorts of files scattered thru it. I want to sync any markdown documents plus the whole directory structure (irrespective of whether a folder contains a markdown document or not). I feel like the following ignore patterns should accomplish this, but I can’t quite get it to work.
(?i)!*.md // include all markdown docs - works correctly
!/**/ // include all folders but not files
* // exclude all other files
I’ve played with the order and tried adding /**/*, but either I manage to sync all files, or only markdown files and the folders that contain them. But what I want is all folders but only markdown files.
Just to make it clear, the following is the structure on computer A:
and what I want synced to computer B is:
Am I just missing something really obvious, or is this just not possible?
A pattern ending in a forward-slash (/) says “the contents of a directory”.
So !/**/ translates to, “Starting from the root, include any directory’s contents”. Thus if a directory has no matching files, it’s ignored.
Another way to think of it is that a directory is only created in the process of syncing a matching file when the ignore pattern feature is enabled.
There’s no token that matches an empty directory so the only method that comes to mind at the moment is to exclude all files you don’t want, leaving just the Markdown files and directory names like this…
The ordering of the rules is important. Like Syncthing, the first match causes all following patterns to be ignored for the file/directory being inspected.
So the filter above breaks down to:
Line 1: First, include the contents of snap/firefox/common/.mozilla/ otherwise it will be excluded by line 5.
Line 2: Include the contents of snap/firefox/common/ because otherwise the .mozilla/ directory will be excluded by line 5.
Line 3: Likewise, include the contents of snap/firefox/ because otherwise the common/ directory will be excluded by line 5.
Line 4: Ditto, the snap/ directory is required otherwise the firefox/ directory will be excluded by line 5.
Line 5: Finally, exclude everything under the snap/ directory that hasn’t already been explicitly included.
My Duplicacy filter currently contains 59 patterns. I decided to let some small files be included rather than maintain a more complicated filter, but I’ve seen users posting that their filters are much more elaborate.
Just a minor nitpick, you don’t need to use ** in the first pattern, as it’s exactly the same as just * in this case. ** itself is useful when matching something inside all subfolders of a particular path, e.g. folder/**/*.md, etc.