The installed version of rclone is rclone v1.50.2 on Ubuntu 18.04 LTS. The remote is DropBox.
When attempting to run the command rclone ls --filter '+ *.pdf' dropbox:, the results include files with extensions other than .iso. For example, .docx, .txt and so on.
If the command rclone ls --include '*.pdf' dropbox: is used, it returns only files with a pdf file extension whereas rclone ls --include '+ *.pdf' dropbox: results in no files.
In contrast the command rclone ls --filter '*.pdf' dropbox:displays the error Failed to load filters: malformed rule "*.pdf"
Thanks for clearing that up @ncw. It would suggest that --include is far more efficient and effective. What are some examples --filter could be used for that --include could not or should not?
I did read it before posting however it isn't clear. It may be the way I understood it.
For example, the excerpt below (emphasis mine) suggests that --filtershould be used for a single include or exclude. It suggests (based on my interpretation) that if I construct a command such as --filter '+ *.pdf, it should only return the output with files that have a .pdf extension which isn't the case.
This can be used to add a single include or exclude rule. Include rules start with + and exclude rules start with - . A special rule called ! can be used to clear the existing rules.
This flag can be repeated. See above for the order the flags are processed in.
Eg --filter "- *.bak" to exclude all bak files from the sync.
Thanks @Animosity022. The examples are great. It isn't clear though..
For example why I would use --filter '+ *.pdf --filter '- *' if I can simply use--include '*.pdf. The former seems far more complicated in that I have to explicitly exclude all.
--exclude '*.pdf' and --filter '- *.pdf' seem to result in the same output.
I personally would use what works best for the situation. You have options to use what works best for your use case so not everything is black and white.
For your example, I'd just use include as that best and most simply solves the problem.
filter gives much more flexibility in terms of setting up a longer list.
A hammer opens everything but it is not always the right tool to use
, yes I am in complete agreement in not using a hammer for everything. I was hoping that you may be able to shed light on examples of when --filter is a better choice than --include. The reason being is that it would help filter (pun intended) the choices in using either flags.
Filter would be used if you would have a more complex set of rules that you wanted to process and most folks use filter-from so they have it all in a file.
It does top down processing of the rules and you have a lot of flexibility to create a set of rules that meet some interesting needs.
Gives a pretty good one. Also, you can't mix include and exclude together so in cases where you need both an include and exclude, filter would be the option.