Works with any rclone remote, and at the end it spits out a file that can be used as a --filter-from.
I'm still working on it but was excited about it and thought I'd share It is written in Go and very much inspired by rclone's ncdu and tree. It supports both - ** and + ** modes, and can also dump filters as regex, and it is careful about the rule order and avoiding redundancy. It all runs through rclone's actual filter module in realtime, so you can see exactly what you're getting.
1 bad decision though: You expect rclone to be 'installed'/configured on the target system. Write your output file rather in the current folder rclone is run from.
2023/12/17 13:54:13 NOTICE: Example usage:
rclone tree "C:\" --filter-from "C:\Users\[user]\AppData\Local\rclone\rclone_genfilters.txt"
2023/12/17 13:54:13 ERROR : C:\Users[user]\AppData\Local\rclone\rclone_genfilters.txt: error writing file: open C:\Users[user]\AppData\Local\rclone\rclone_genfilters.txt: The system cannot find the path specified.
2023/12/17 13:54:13 ERROR : C:\Users[user]\AppData\Local\rclone\rclone_genfilters.txt: error writing file: invalid argument
Is there a different dir that would be a better default?
IMO yes, as I said: Follow Win/*nix standards - the current dir if no other is specified.
(Also I dislike 3rd party tools writing to other apps config(dirs), IMO a bad practice.
But maybe @ncw likes to integrate your work into standard rclone?).
another possible improvement:
Allow (use) wider screens, (allow to) put the tree more to the right so the filter text isn't cut after a few characters.
edit:
Dunno if a program can read screen parameters but 50% of the width appears a pretty good place as standard to place the tree so tree and filter have the same space to display looong names.
I think the bug you're referring to was a bug in go1.21.4 (not technically a bug in rclone.) The genfilters binaries were compiled with go1.21.5, which probably explains why it is fixed. So I can't take credit It is probably also fixed in the latest official beta of rclone.
Technically it is a bug in rclone.
I've been a programmer too 'in my former life', the components I decided to use (to save much work) were my responsibility.
Did Nick do anything wrong? No, not at all! Still the software failed, so it had a bug.
Generated filters.txt by genfilters and tried mounting with --filter-from=filters.txt, there seems a bug cannot handling square brackets. Am I the only one experiencing this problem?
I think the issue is probably that square brackets in filter patterns are interpreted as a character-range, so they need to be escaped with \ if you want them interpreted literally.
For example, instead of:
- /filewith[brackets]inname
try:
- /filewith\[brackets\]inname
But I agree genfilters should probably be smarter about detecting this and escaping automatically! Thank you for bringing this to my attention -- I have some revisions planned already and I will try to include this