Perhaps (hopefully) there is a different approach to work around your challenge, but I will just try to answer the question about filtering:
General regex syntax is not supported in rclone, your example ^\w{5,10}
will not work. Rclone uses the following kind of patterns:
The patterns used to match files for inclusion or exclusion are based on "file globs" as used by the unix shell.
Though, typical regex character classes are supported:
A [
and ]
together make a character class, such as [a-z]
or [aeiou]
or [[:alpha:]]
.
So the corresponding to \w
would be [[:word:]]
. To match a generic path/file string, would you not want to include any character, such as punctuation, not just [0-9A-Za-z_]
? I would at least use [[:graph:]]
. But still there are a lot of characters, with accents etc, that will not be included. So why not include any character:
A ?
matches any character except a slash /
.
To mach any character, including path separator, we could use the following syntax:
A {
and }
define a choice between elements.
So the following will match any character in a generic path string:
{/,?}
Now, I don't think you can specify number of repititions with rclone. One very, very, naive approach would be to generate an include file matching all possibilities from 1 to 255 characters long path:
/?{?,/}
/?{?,/}{?,/}
/?{?,/}{?,/}{?,/}
/?{?,/}{?,/}{?,/}{?,/}
/?{?,/}{?,/}{?,/}{?,/}{?,/}
/?{?,/}{?,/}{?,/}{?,/}{?,/}{?,/}
/?{?,/}{?,/}{?,/}{?,/}{?,/}{?,/}{?,/}
etc...
Every line begins with /
to always match from start of the path (from top level of your directory tree), and then with an ?
since the path must contain at least one character. Then repeating {?,/}
to match either characters or path separators x number of times from 1 to 254, to match any path from 1 to 255 characters. (possibly -1 if first /
of paths should be counted in?).
Using Powershell you can generate a filter file with all 254 lines like this:
1..254 | % { '/?'+('{?,/}'*$_) } | Out-File myfilterfile.txt -Encoding utf8
Test it with rclone ls command, and see which files would be included:
rclone ls jfs:/Test --include-from myfilterfile.txt
Or probably more revealing: Which files would be excluded:
rclone ls jfs:/Test --exclude-from myfilterfile.txt