--filter-from and directories

What is the problem you are having with rclone?

I have the following lines in my filter file

- /University/PoliMi/Master/
- /University/PoliMi/Master/Courses/Done/Cryptography/Rec/
+ /University/PoliMi/Master/Courses/Done/Cryptography/

The idea is to exclude all the content of the Master directory, while at the same time include the Master/Courses/Done/Cryptography/ directory. From the latter, I want to exclude the Rec/ subdirectory. However, the Cryptography directory is not synced at all, so I suspect this is not the way to proceed.

I tried to replace the last slash / with ** in the Master line, i.e. /University/PoliMi/Master**, but nothing changed. So, what is the correct way to exclude a whole directory, except for some specific subdirectory? I couldn't find any example in the documentation.

What is your rclone version (output from rclone version)

rclone v1.54.1
- os/arch: linux/amd64
- go version: go1.16

Which OS you are using and how many bits (eg Windows 7, 64 bit)

ArchLinux 64-bit

Which cloud storage system are you using? (eg Google Drive)

OneDrive for Business

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

rclone ls polimi: --filter-from file.txt

The rclone config contents with secrets removed.

[polimi]
type = onedrive
region = global
drive_type = business

A log from the command with the -vv flag

Not sure if it's useful, I guess is more me failing in understanding how filters work, but if it can be useful I will provide one.

hello and welcome to the forum,

filter can be very confusing
i think there are two ways to get this done

first way is to change the order of items in the --filter-from
based on the docs
"Within --include-from, --exclude-from and --filter-from flags rules are processed from top to bottom of the referenced file."

+ /University/PoliMi/Master/Courses/Done/Cryptography/
- /University/PoliMi/Master/
- /University/PoliMi/Master/Courses/Done/Cryptography/Rec/

second way
filters are applied in a certain order of precedence, you can read about it here
"The order in which rules are processed can influence the result of the filter."

  1. add a --include-from for /University/PoliMi/Master/Courses/Done/Cryptography/
  2. remove /University/PoliMi/Master/Courses/Done/Cryptography/ from the --filter-from

Hi @asdffdsa , thanks for your reply.
I prefer the filter method in order to avoid passing different flags from the command line each time and as a quick reference. I indeed tried the first way, but there's no difference.

<7>DEBUG : University/PoliMi/Master: Excluded

no worries, here comes @Animosity022

Filters work on a first matched basis so if you match something, no further filters are applied:

Each path/file name passed through rclone is matched against the combined filter list. At first match to a rule the path/file name is included or excluded and no further filter rules are processed for that path/file.

felix@flux:~$ rclone ls /home/felix/test
        0 PoliMi/Master/one
        0 PoliMi/Master/Courses/Done/Cryptography/three
        0 PoliMi/Master/Courses/Done/Cryptography/Rec/two
felix@flux:~$ cat filter
- PoliMi/Master/Courses/Done/Cryptography/Rec/**
+ PoliMi/Master/Courses/Done/Cryptography/**
- **
felix@flux:~$ rclone ls /home/felix/test --filter-from filter
        0 PoliMi/Master/Courses/Done/Cryptography/three
felix@flux:~$

So you want to be careful on the order

You'd want to put your most restrictive / specific matches on the top and work your way down to the least restrictive since the first match stops the rules processing.

Thanks to both of you, I didn't think of this interleaved scenario and now it makes more sense.

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