Negating of character class in regex pattern does not work

What is the problem you are having with rclone?

It looks like that negating of character class in regex pattern does not work properly

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

rclone v1.69.3
* os/version: Microsoft Windows 10 Pro 22H2 22H2 (64 bit)
* os/kernel: 10.0.19045.6093 (x86_64)
* os/type: windows
* os/arch: amd64
* go/version: go1.24.3
* go/linking: static
* go/tags: cmount

Which cloud storage system are you using?

Jottacloud

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

deleting files which names are starting with 'R' character

rclone delete meetingpoint-jotta:WSUS --include=/{{[R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

this command works as expected, but when I try to delete files which names DO NOT start with 'R' character

rclone delete meetingpoint-jotta:WSUS --include=/{{[^R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

rclone tries to remove same files as in previous command.
Same behavior I can observe when I try to use same include patterns on local disk (NTFS formatted):

rclone delete . --include=/{{[R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

and

rclone delete . --include=/{{[^R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

tries to remove same set of files

The rclone config contents with secrets removed.

[meetingpoint-jotta]
type = jottacloud
configVersion = 1
client_id = jottacli
client_secret =
tokenURL = https://id.jottacloud.com/auth/realms/jottacloud/protocol/openid-connect/token
token = {"access_token":"****","token_type":"Bearer","refresh_token":"****","expiry":"2025-08-15T12:40:24.7127609+02:00"}
device =
mountpoint =

A log from the command with the -vv flag

rclone delete meetingpoint-jotta:WSUS --include=/{{[R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

2025/08/15 12:11:07 DEBUG : rclone: Version "v1.69.3" starting with parameters ["rclone" "delete" "meetingpoint-jotta:WSUS" "--include=/{{[R].*}}" "--dry-run" "-vv" "--password-command" "powershell C:\\Users\\user1\\AppData\\Roaming\\rclone\\read-pfile.ps1"]
2025/08/15 12:11:07 DEBUG : Creating backend with remote "meetingpoint-jotta:WSUS"
2025/08/15 12:11:08 DEBUG : Using config file from "C:\\Users\\user1\\AppData\\Roaming\\rclone\\rclone.conf"
2025/08/15 12:11:08 DEBUG : Waiting for deletions to finish
2025/08/15 12:11:08 DEBUG : Approves4Host.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : Approves4Parents.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : FileVersion.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : FileVersionNew_v1.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : FileVersionNew_v2.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : GetDetailedReport4Group.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : GetSummaryReports4Group.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : GetUpdatesArrivedOnDate.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : GetUpdateState_v1.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : GetUpdateState_v2.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : List-InstalledPatches.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : List-InstalledPatches2.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : List-InstalledPatchesNew.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : UpdatesReport.ps1: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : wsus_clean_obsolete_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : wsus_decline_superseeded_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : wsus_reindex_database_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : wsus_remove_driver_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:11:08 DEBUG : wsus_remove_hidden_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:11:08 NOTICE: RegKeysContent_v2.ps1: Skipped delete as --dry-run is set (size 4.375Ki)
2025/08/15 12:11:08 NOTICE: RegKeysContent_v1.ps1: Skipped delete as --dry-run is set (size 4.385Ki)
2025/08/15 12:11:08 DEBUG : 8 go routines active
rclone delete meetingpoint-jotta:WSUS --include=/{{[^R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

2025/08/15 12:10:52 DEBUG : rclone: Version "v1.69.3" starting with parameters ["rclone" "delete" "meetingpoint-jotta:WSUS" "--include=/{{[R].*}}" "--dry-run" "-vv" "--password-command" "powershell C:\\Users\\user1\\AppData\\Roaming\\rclone\\read-pfile.ps1"]
2025/08/15 12:10:52 DEBUG : Creating backend with remote "meetingpoint-jotta:WSUS"
2025/08/15 12:10:53 DEBUG : Using config file from "C:\\Users\\user1\\AppData\\Roaming\\rclone\\rclone.conf"
2025/08/15 12:10:53 DEBUG : Waiting for deletions to finish
2025/08/15 12:10:53 DEBUG : Approves4Host.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : Approves4Parents.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : FileVersion.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : FileVersionNew_v1.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : FileVersionNew_v2.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : GetDetailedReport4Group.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : GetSummaryReports4Group.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : GetUpdatesArrivedOnDate.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : GetUpdateState_v1.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : GetUpdateState_v2.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : List-InstalledPatches.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : List-InstalledPatches2.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : List-InstalledPatchesNew.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : UpdatesReport.ps1: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : wsus_clean_obsolete_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : wsus_decline_superseeded_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : wsus_reindex_database_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : wsus_remove_driver_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:10:53 DEBUG : wsus_remove_hidden_updates_sql_script.docx: Excluded (Path Filter)
2025/08/15 12:10:53 NOTICE: RegKeysContent_v2.ps1: Skipped delete as --dry-run is set (size 4.375Ki)
2025/08/15 12:10:53 NOTICE: RegKeysContent_v1.ps1: Skipped delete as --dry-run is set (size 4.385Ki)
2025/08/15 12:10:53 DEBUG : 8 go routines active
rclone delete . --include=/{{[R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

2025/08/15 12:46:40 DEBUG : rclone: Version "v1.69.3" starting with parameters ["rclone" "delete" "." "--include=/{{[R].*}}" "--dry-run" "-vv" "--password-command" "powershell C:\\Users\\user1\\AppData\\Roaming\\rclone\\read-pfile.ps1"]
2025/08/15 12:46:40 DEBUG : Creating backend with remote "."
2025/08/15 12:46:40 DEBUG : Using config file from "C:\\Users\\user1\\AppData\\Roaming\\rclone\\rclone.conf"
2025/08/15 12:46:40 DEBUG : fs cache: renaming cache item "." to be canonical "//?/D:/Archiwum/user1/Scripts"
2025/08/15 12:46:40 DEBUG : Waiting for deletions to finish
2025/08/15 12:46:40 NOTICE: REncrypt-File.ps1: Skipped delete as --dry-run is set (size 5.962Ki)
2025/08/15 12:46:40 NOTICE: REncrypt-FileOrig.ps1: Skipped delete as --dry-run is set (size 5.104Ki)
2025/08/15 12:46:40 DEBUG : 3 go routines active
rclone delete . --include=/{{[^R].*}} --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"

2025/08/15 12:46:51 DEBUG : rclone: Version "v1.69.3" starting with parameters ["rclone" "delete" "." "--include=/{{[R].*}}" "--dry-run" "-vv" "--password-command" "powershell C:\\Users\\user1\\AppData\\Roaming\\rclone\\read-pfile.ps1"]
2025/08/15 12:46:51 DEBUG : Creating backend with remote "."
2025/08/15 12:46:51 DEBUG : Using config file from "C:\\Users\\user1\\AppData\\Roaming\\rclone\\rclone.conf"
2025/08/15 12:46:51 DEBUG : fs cache: renaming cache item "." to be canonical "//?/D:/Archiwum/user1/Scripts"
2025/08/15 12:46:51 DEBUG : Waiting for deletions to finish
2025/08/15 12:46:51 NOTICE: REncrypt-File.ps1: Skipped delete as --dry-run is set (size 5.962Ki)
2025/08/15 12:46:51 NOTICE: REncrypt-FileOrig.ps1: Skipped delete as --dry-run is set (size 5.104Ki)
2025/08/15 12:46:51 DEBUG : 2 go routines active

Update rclone as you have an old version and test again. You can just use ls rather than delete for testing.

$ touch aaa bbb ccc ddd eee

$ rclone ls . --include=/{{[a].*}}
        0 aaa

$ rclone ls . --include=/{{[^a].*}}
        0 bbb
        0 ccc
        0 ddd
        0 eee

Hi,

I’ve updated rclone to 1.70.3:

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

but it does not help. Still using --include=/{{[R].*}} and --include=/{{[^R].*}} give the same set of files

can you try with ls as in my example? BTW - I’ve tried delete and it works too. But ls is easier for testing.

Also, in English what are you trying to make happen?

vs.

See second lines. It is the same command. Must be something to do with shell you are using. Try quoting etc. I am not Windows expert. Your shell is stripping “^“

d:\temp>dir
 Volume in drive D is Archiwum_1
 Volume Serial Number is CC79-90E4

 Directory of d:\temp

2025-08-15  13:18    <DIR>          .
2025-08-15  13:18    <DIR>          ..
2025-08-15  13:18                 0 aaaa.txt
2025-08-15  13:18                 0 bbbb.txt
2025-08-15  13:18                 0 cccc.txt
2025-08-15  13:18                 0 dddd.txt
2025-08-15  13:18                 0 eeee.txt
               5 File(s)              0 bytes
               2 Dir(s)  145 176 895 488 bytes free
d:\temp>rclone ls . --include=/{{[a].*}} --dry-run  --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"
        0 aaaa.txt

d:\temp>rclone ls . --include=/{{[^a].*}} --dry-run  --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"
        0 aaaa.txt

I thing the second ls command should list all files but not aaaa.txt

You are right! It looks like cmd.exe stripping “^“. I have to investigate it. Thank you

try

rclone ls . --include='/{{[^a].*}}'

or

rclone ls . --include="/{{[^a].*}}"

if does not help then Google about your shell’s quirks.

Try running it in PowerShell as CMD uses ^ as an Escape Command kind of like \ on Linux.

I think in CMD, you do a ^^ instead.

I’ve found solution: when I take pattern in quotation marks like --include="/{{[^R].*}}" cmd.exe does not strip "^"

rclone ls . --include="/{{[^a].*}}" --dry-run -vv --password-command "powershell %APPDATA%\rclone\read-pfile.ps1"
2025/08/15 13:33:29 DEBUG : rclone: Version "v1.70.3" starting with parameters ["rclone" "ls" "." "--include=/{{[^a].*}}" "--dry-run" "-vv" "--password-command" "powershell C:\\Users\\lukas\\AppData\\Roaming\\rclone\\read-pfile.ps1"]
2025/08/15 13:33:29 DEBUG : Creating backend with remote "."
2025/08/15 13:33:29 DEBUG : Using config file from "C:\\Users\\lukas\\AppData\\Roaming\\rclone\\rclone.conf"
2025/08/15 13:33:29 DEBUG : fs cache: renaming cache item "." to be canonical "//?/d:/temp"
        0 bbbb.txt
        0 cccc.txt
        0 dddd.txt
        0 eeee.txt
2025/08/15 13:33:29 DEBUG : 2 go routines active

I just tested that @Animosity022 way also works
thank you all for your instant help

2 Likes

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