I am trying to include “config.xml” in all directories, exclude for the “backups” root-level directory. I tried invoking:
rclone sync --dump-filters --filter “- backups/**” --filter “+ config.xml” source target
and got the following output:
— start filters —
— File filter rules —
— Directory filter rules —
The problem is that this is including non-config.xml files in the root directory. I think “+ ^.*$” is at fault. How do I filter that out?
I figured it out.
According to https://rclone.org/filtering/#how-the-rules-are-used each filter is matched in order, from top to bottom, against the list of filters. So I had to moved the exclusion filters around to get the desired behavior:
–filter “- backups/**” --filter “+ **/config.xml” --filter “- *”
That is, I always exclude “backups” even if they contain “config.xml”. I then exclude all non-config.xml files (at the end of the filter list).
Glad you figured it out. Note that you don’t need the
**/ prefix on the
config.xml as that is the default - do search everwhere for it.