Multiple filters via environment variables

What is the problem you are having with rclone?

I want to pass filters as environmental variables if at all possible.
I tried with the output below with no success.
Is there a way to do it or an alternative strategy I can use to achieve the same result?

Run the command 'rclone version' and share the full output of the command.

rclone v1.57.0
- os/version: ubuntu 20.04 (64 bit)
- os/kernel: 5.4.0-91-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.17.2
- go/linking: static
- go/tags: none


rclone v1.61.1
- os/version: darwin 12.4 (64 bit)
- os/kernel: 21.5.0 (x86_64)
- os/type: darwin
- os/arch: amd64
- go/version: go1.19.4
- go/linking: dynamic
- go/tags: none

Which cloud storage system are you using?

Dropbox via API

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone ls dropbox-api: --filter='- **.rar' --filter='- **.{jpg,png}' --ignore-case --human-readable

The rclone config contents with secrets removed.

type = dropbox
client_id = **CLIENT_ID**
client_secret = **CLIENT_SECRET**
chunk_size = 64Mi
token = {"access_token":"*****","token_type":"bearer","refresh_token":"*****","expiry":"2023-01-07T19:27:57.955966+01:00"}
impersonate =

A log from the command with the -vv flag

rclone ls dropbox-api: --filter='- **.rar' --filter='- **.{jpg,png}' --ignore-case --human-readable --dump filters
2023/01/07 17:21:51 NOTICE: Automatically setting -vv as --dump is enabled
--- start filters ---
--- File filter rules ---
- (?i)(^|/).*\.rar$
- (?i)(^|/).*\.(jpg|png)$
--- Directory filter rules ---
- (?i)(^|/).*\.rar$
- (?i)(^|/).*\.(jpg|png)$
--- end filters ---
... good output ...

RCLONE_FILTER="- **.rar - **.{jpg,png}" rclone ls dropbox-api: --ignore-case --human-readable --dump filters
2023/01/07 17:27:38 NOTICE: Automatically setting -vv as --dump is enabled
--- start filters ---
--- File filter rules ---
- (?i)(^|/).*\.rar - .*\.(jpg|png)$
--- Directory filter rules ---
- (?i)(^|/).*\.rar - .*\.(jpg|png)$
--- end filters ---
... bad output ...

Hi Daniele,

Looks like you can combine the two filters in one like this:

--filter='- **.{jpg,png,rar}'

and then use the environment variable RCLONE_FILTER='- **.{jpg,png,rar}' or RCLONE_EXCLUDE='**.{jpg,png,rar}'. If this is just an example and you want more complicated filtering, then you may have to use RCLONE_FILTER_FROM=myfilterfile.txt

You can find more details here:

Thanks, your example works in this simple case, but I will need some more complex filters and using a file is not always possible.
This is why I was wondering if there's a way to do combine filters.
The only other workaround I found is to include a string in an environment variable and print that string to file.

These are the only possibilities I can see in the documentation. I also briefly checked the code to see if a linefeed (ASCII 10) perhaps could be used as a secret delimiter hack, but don't think so.

So your workaround seems to be the best solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.