Best way to use multiple filters from a script?

I noticed on the Filtering documentation page this warning:

Important Due to limitations of the command line parser you can only use any of these options once - if you duplicate them then rclone will use the last one only.

It seems like the only method for specifying multiple filters is via a filter file. This is problematic for me, as I’m writing a backup script and while I’d like to have certain filters built in as a base, I also want the flexibility to pass in additional ones as a given backup job requires. If all I can use is a file or a single exclude rule, then this becomes very, very difficult.

For example, I’m on macOS so I’d like my base to exclude all manner of cruft that macOS puts everywhere (Icon\r, .DS_Store, all manner of invisible directories at the root of a volume, etc). However, a given backup job might also need to exclude a folder or files of its own. With rsync I’d just keep appending more filters to the command and call it a day, but rclone doesn’t sound like it will handle that.

Any ideas?

That is the case yes. However the command line parser rclone uses was recently extended so you can have multiple copies of each flag so I should probably use that. I made an issue about it here:

Take a look at that ticket and see if it would satisfy your requirements.

You ca achieve this with a bit of shell scripting. Make your file with the base rules called base-excludes say. You can then copy this to a new fie and echo >> new rule to put stuff on the end.