Exclude all files/dirs in sub-subdirectories

Hi. I have a structure like this:

dir1/
  dir2/
    file1
  dir3/
  file2

Using the filtering mechanism, is there any way to say include dir1, dir2, dir3, and file2, but exclude everything below them, such as file1? There are many more files and directories in dir1 than in my example, and they change over time, so I can't easily make a static list. Just curious. Thanks!

Most definitely, but you need some way to identify what files you want to exclude. You can do it via files, via directories or however you want.

If you can provide how you want the logic to work, I'm sure someone can help out.

https://rclone.org/filtering/

Well, that's the thing. The only logic is that I went to backup everything directly under dir1, and I want to exclude everything further below dir1. But I don't know any explicit names, so it'd have to use a regexp somehow.

Thanks.

That's actually simpler:

[felix@gemini dir1]$ rclone ls /home/felix/test/dir1 --max-depth 1
        0 test
        0 test2
[felix@gemini dir1]$ rclone ls /home/felix/test/dir1 --max-depth 2
        0 test
        0 test2
        0 1/hosts

You can just max-depth 1.

Ah, good point. But to complicate things... dir1 is actually a directory deep in my home directory. I have a single rclone job that backs up my home directory. So, this isn't some isolated thing, which is why I was hoping to be able to use a filter. Thanks again!

Can you share specifically what your structure looks like and what you want to back up? I can't quite follow your logic on what you want to do.

Here's a more complete idea of the directory structure:

/home/reid/dir0_0
          /dir0_1
          /dir0_2
          /dir0_3
              dir1/
                 dir2/
                    file1
                 dir3/
                 file2

I have a single rclone job that backs up entire home directory. I want it to back up everything except files and directories that are more than depth 1 under dir1. In this simple case, that would be file1, but there could be more.

So you could do something like using ignore files and exclude if present:

https://rclone.org/filtering/#exclude-directory-based-on-a-file

If you want to ignore and worry less about trying to tweak a filter.

I wasn't aware of that, thanks.

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