Match directory based on name, no matter where it is

What is the problem you are having with rclone?

I'm looking for a way to exclude files and directories based on their names, no matter where they are located. I'm using the syntax as recommended by the docs, **/cache/, however this does not match files at the root. I have about 50 of these exclusions based on folder name, and I'd like to avoid having to create two entries for each directory name, i.e.

cache/
**/cache/

Is there a better way which matches a directory name at all levels, even at root? My overarching goal is to back up my entire AppData while excluding all the cache and temp files, that's why I have ~50ish directory name exclusions.

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.5854 (x86_64)
  • os/type: windows
  • os/arch: amd64
  • go/version: go1.24.3
  • go/linking: static
  • go/tags: cmount

Are you on the latest version of rclone? You can validate by checking the version listed here: Rclone downloads
yes

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

not applicable

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

rclone copy "C:\Users\REDACTED\AppData" "C:\Users\REDACTED\Desktop\test" --exclude-from "rclone_exclude.txt" --ignore-case --progress

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

not applicable

welcome to the forum,

cache/ should exclude all directories named cache and it contents.

sorry, not clear on your setup and what exactly you are trying to exclude?


best to create a simple set of test folders and test on that.

rclone touch b:\username\appdata\a.ext 
rclone touch b:\username\appdata\cache\b.ext 
rclone touch b:\username\appdata\folder\c.ext 
rclone touch b:\username\appdata\folder\cache\d.ext 
rclone touch b:\username\appdata\folder\cache\folder\e.ext 

rclone tree b:\username\appdata 
/
├── a.ext
├── cache
│   └── b.ext
└── folder
    ├── c.ext
    └── cache
        ├── d.ext
        └── folder
            └── e.ext

rclone tree b:\username\appdata --exclude=cache/ 
/
├── a.ext
└── folder
    └── c.ext
1 Like

Thank you, cache/ is perfect and what I was looking for, I guess I overcomplicated it with **/cache/.