Exclude on Windows path with [] characters

Hi there, I’m trying to sync fotos to amazon drive which works fine. But I’m not able to exclude files in a folder called [Originaldateien]. -exclude β€œ**/[Originaldateien]/*” does not work on Windows (10, 64 bit).
Here the exclude command again since the formatter is eating my backslashes :wink:

-exclude "**/\[Originaldateien\]/*"

That looks like it should work - what does --dump-filters -vv say?

Here is (a small) part of the log:

--- start filters ---

β€” File filter rules β€”

  • (^|/)[^/]*.jpg$
  • (^|/)./[Originaldateien]/[^/]$
  • (^|/)[^/]*$
  • ^.*$
    β€” Directory filter rules β€”
  • ^.*$
  • (^|/)./[Originaldateien]/[^/]$
  • ^.*$
    β€” end filters β€”
    …
    2017/04/10 20:28:16 DEBUG : amazon drive root β€˜β€™: Finished reading β€œ2016/2016_09/Italien/Castel del Monte/[Originaldateien]/”
    2017/04/10 20:28:16 DEBUG : 2016/2016_09/Italien/Castel del Monte/[Originaldateien]/2016_09_05-13_35_34.jpg: Sizes identical
    2017/04/10 20:28:16 DEBUG : 2016/2016_09/Italien/Castel del Monte/[Originaldateien]/2016_09_05-13_57_48.jpg: Sizes identical
    2017/04/10 20:28:16 DEBUG : 2016/2016_09/Italien/Castel del Monte/[Originaldateien]/2016_09_05-13_57_48.jpg: Unchanged skipping
    …

The order of the filters:
–exclude β€œ**/[Originaldateien]/" --include ".jpg” --exclude β€œ*”

If you want to exclude all files in a folder then you need -exclude "**/\[Originaldateien\]/**" which is the same as -exclude "\[Originaldateien\]/**"

Unfortunately this doesn’t help much:

--exclude "**/\[Originaldateien\]/**"`

2017/04/10 21:29:50 DEBUG : amazon drive root β€˜β€™: Finished reading β€œ2007/2007_10/Lanzarote/[Originaldateien]/”
2017/04/10 21:29:50 DEBUG : 2007/2007_10/Lanzarote/[Originaldateien]/2007_11_02-15_48_53.jpg: Sizes identical
2017/04/10 21:29:50 DEBUG : 2007/2007_10/Lanzarote/[Originaldateien]/2007_11_02-15_48_53.jpg: Unchanged skipping

--exclude "/\[Originaldateien\]/**"`

2017/04/10 21:36:04 DEBUG : amazon drive root β€˜β€™: Finished reading β€œ2016/2016_09/Italien/Grotte de Castellana/[Originaldateien]/”
2017/04/10 21:36:04 DEBUG : 2016/2016_09/Italien/Grotte de Castellana/[Originaldateien]/2016_09_09-11_12_31.jpg: Sizes identical
2017/04/10 21:36:04 DEBUG : 2016/2016_09/Italien/Grotte de Castellana/[Originaldateien]/2016_09_09-11_12_11.jpg: Sizes identical
2017/04/10 21:36:04 DEBUG : 2016/2016_09/Italien/Grotte de Castellana/[Originaldateien]/2016_09_09-11_12_11.jpg: Unchanged skipping

I did a little test on linux and everything works fine

$ rclone ls .
        0 2007/2007_10/Lanzarote/[Originaldateien]/2007_11_02-15_48_53.jpg
$ rclone ls . --exclude "**/\[Originaldateien\]/**"
$ rclone ls . --exclude "**/\[Originaldateien\]/**" --dump-filters
--- start filters ---
--- File filter rules ---
- (^|/).*/\[Originaldateien\]/.*$
--- Directory filter rules ---
- (^|/).*/\[Originaldateien\]/.*$
--- end filters ---

I see the problem now though, in your --dump-filters output you have

- (^|/)./[Originaldateien]/[^/]$

whereas I have (note the extra \ before the [ and ])

- (^|/).*/\[Originaldateien\]/.*$

So what must be happening is the windows shell is eating the \ inside the β€œβ€.

Try doubling up the \ like this

--exclude "**/\\[Originaldateien\\]/**"`

It’s not that easy :wink:

–exclude β€œ/\[Originaldateien\]/**” (wow, now this formatter eats the extra 's too, there are two of them (\\) in front of the brackets [])

--- start filters ---
--- File filter rules ---
+ (^|/)[^/]*\.jpg$
+ (^|/)[^/]*\.JPG$
- ^\\[Originaldateien\\]/.*$
- (^|/)[^/]*$
- ^.*$
--- Directory filter rules ---
+ ^.*$
- ^\\[Originaldateien\\]/.*$
- ^.*$
--- end filters ---

2017/04/11 18:18:45 DEBUG : amazon drive root β€˜β€™: Finished reading β€œ2005/2005_01/Binz/[Originaldateien]/”
2017/04/11 18:18:45 DEBUG : 2005/2005_01/Binz/[Originaldateien]/2005_01_21-14_48_26.jpg: Sizes identical