How to exclude ALL subdirectories from rclone copy

I asked this question on github (sorry), so I am reposting it here with the answer I got back...

When I use rclone copy, I know I can use --exclude "/some-dir-name/**" to exlcude that specific dir.

But how do I exclude all sub dirs, and only copy the root?

Also, how can I include only specific file types from the root , like *.mp4 only?

Thanks

ANSWER that I got from NCW on GitHub:

You can do it with filters like this (+ being INCLUDE and - being EXCLUDE)

--filter "+ /*" --filter "- *"

Perhaps easier is

--max-depth 1

Also, how can I include only specific file types from the root , like *.mp4 only?

--filter "- /*.mp4"

I'd use:

https://rclone.org/filtering/#filter-from-read-filtering-patterns-from-a-file

and just put a few things together.

max-depth 1 will only do the root and you can build your logic for what you want.

So just mp4 extensions would be something like:

+ *.mp4
# exclude everything else
- *

If I wanted to use just --filter instead of --filter-from file, would I have to put seperate filter commands like this:

--max-depth 1 --filter "+ *.mp4" --fliter "- *"

Or can they be combined together?

Sure, that works.

I find a file to be easier to maintain and view for me.

You can always use --dry-run or validate it's doing what you want with rclone ls command as well.

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