It would be nice to be able to use rclone glob filtering to exclude NOT matches. For example,
A/
B/
C/
to be able to say "NOT /A/** OR /C/**"
To help clarify, it may be helpful for me to say what is currently missing (and maybe I am also wrong!)
Why not regex
Regex can absolutely do this except that regex breaks directory filter rule optimization. At least in my use case, this makes it way too slow to use
Docs:
If any regular expression filters are in use, then no directory recursion optimisation is possible, as rclone must check every path against the supplied regular expression(s).
Why not include A/ and C/"
The reason not to just use a filter rule like:
+ /A/**
+ /C/**
- **
is that rclone will then keep all of /A and all of /C regardless of other filters. If I had no other filters, this would work but it is not general enough. Also, you need to know all directories in the remote besides the ones you don't want
Why not sync remote:A/ rather than remote:
The biggest reason is that I could have other anchored filters (e.g. - /A/sub/**) which would break.
Second is that you need to know the top level directories and need a sync call for each.
(This is actually my current approach but it adds this risk).
Again, I may be mistaken on whether this is possible currently, but the alternatives I laid out are the best I could think of and are insufficient for the reasons I mentioned.
So -! would mean "exclude everything but" and +! would mean "include everything but".
It is always possible to re-arrange the rules so -! and +! aren't needed I think but in this specific case of combining rules it would be very useful.
Given that ! on its own isn't a valid regular expression, we could introduce this feature with {{!}} instead, to mean this match should be inverted. In that case your example would look like