Exclude using regex filtering

What is the problem you are having with rclone?

Filtering using regex

I've tried the following so far

  • **.r{[0-9]+}
  • **.r([0-9]+)
  • **.r[0-9]+
  • **.r[[:digit:]]+

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

- os/version: Microsoft Windows 10 Pro 22H2 (64 bit)
- os/kernel: 10.0.19045.4529 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.19.3
- go/linking: static
- go/tags: cmount

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

windows 10 to sftp on the fly remote

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

D:\bin\rclone\rclone.exe move "D:/Users/****/Documents/pve/mmc" :sftp:"/home/****/Documents/pve/mmc" --sftp-host "****" --sftp-user "****" --sftp-pass "****" --sftp-shell-type "unix" --sftp-md5sum-command "md5sum" --sftp-sha1sum-command "sha1sum" --checkers 18 --checksum --delete-empty-src-dirs --exclude "**.r{[0-9]+}" --dry-run --fast-list --log-level INFO --low-level-retries 1 --retries 1 --stats 0 --stats-file-name-length 75 --transfers 9 --use-mmap

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

N/A using on the fly remote

A log from the command that you were trying to run with the -vv flag

2024/07/07 22:10:33 DEBUG : Creating backend with remote "D:/Users/****/Documents/pve/mmc"
2024/07/07 22:10:37 DEBUG : Using config file from "D:\\Users\\****\\.config\\rclone\\rclone.conf"
2024/07/07 22:10:43 DEBUG : fs cache: renaming cache item "D:/Users/****/Documents/pve/mmc" to be canonical "//?/D:/Users/****/Documents/pve/mmc"
2024/07/07 22:10:43 DEBUG : Creating backend with remote ":sftp:/home/****/Documents/pve/mmc"
2024/07/07 22:10:43 DEBUG : :sftp: detected overridden config - adding "{fq_wK}" suffix to name
2024/07/07 22:10:43 DEBUG : sftp://****@****:22//home/****/Documents/pve/mmc: New connection ****:59165->****:22 to "SSH-2.0-OpenSSH_9.2p1 Debian-2"
2024/07/07 22:10:43 DEBUG : sftp://****@****:22//home/****/Documents/pve/mmc: Shell type "unix" from config
2024/07/07 22:10:43 DEBUG : sftp://****@****:22//home/****/Documents/pve/mmc: Using root directory "/home/****/Documents/pve/mmc"
2024/07/07 22:10:43 DEBUG : fs cache: renaming cache item ":sftp:/home/****/Documents/pve/mmc" to be canonical ":sftp{fq_wK}:/home/****/Documents/pve/mmc"
2024-07-07 22:10:43 NOTICE: test.r01: Skipped move as --dry-run is set (size 0)
2024-07-07 22:10:43 NOTICE: test.r00: Skipped move as --dry-run is set (size 0)
2024-07-07 22:10:45 INFO  : There was nothing to transfer```

this should work

Thanks that did work yes, it seems it's the curly brackets that I was missing.

I did check Rclone Filtering and syntax package - regexp/syntax - Go Packages but saw no mention of needing to use the two opening and closing curly brackets.

Not sure if the two curly brackets are specific to Go itself or rclone, but that probably should be mentioned somewhere.

This also works **.r{{[0-9]+}}.

tl;dr - rclone and it is mentioned, tho confusing.
"The regular expressions used are as defined in the Go regular expression reference.
Regular expressions should be enclosed in {{ }}"

well, for a bit of background, i once tried to use regex, which worked but should not have. in fact a bug.

which lead to this github issue.
filter: add `{{ regexp }}` syntax to pattern matches - fixes #4074 by ncw · Pull Request #5700 · rclone/rclone · GitHub

1 Like

Ah I see, interesting, thanks!

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