Seems that --exclude don't work with --remove-empty-dirs on bisync command

What is the problem you are having with rclone?

I am trying to run the bisync command with the --remove-empty-dirs option to remove all empty directories, but I want it to ignore the .stfolder directory and not act on it, for that I am using an --exclude but it seems to ignore it.

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

$ rclone --version
rclone v1.63.0
- os/version: arch (64 bit)
- os/kernel: 6.2.10-1-aarch64-ARCH (aarch64)
- os/type: linux
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.20.5
- go/linking: dynamic
- go/tags: none

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

It's Dropbox, but I think it happens with any storage backend.

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

rclone -vv --dry-run \
  --stats 10m --transfers 16 \
    --exclude .stfolder \
    bisync --remove-empty-dirs \
    dropbox: /mnt/dropbox/

The rclone config contents with secrets removed.

[dropbox]
type = dropbox
token = {"access_token":"thetoken","token_type":"bearer","refresh_token":"theothertoken","expiry":"thedate"}

A log from the command with the -vv flag

2023/08/01 09:04:15 DEBUG : rclone: Version "v1.63.0" starting with parameters ["rclone" "-vv" "--dry-run" "--stats" "10m" "--transfers" "16" "--exclude" ".stfolder" "bisync" "--remove-empty-dirs" "dropbox:" "/mnt/dropbox/"]
2023/08/01 09:04:15 DEBUG : Creating backend with remote "dropbox:"
2023/08/01 09:04:15 DEBUG : Using config file from "/home/user/.config/rclone/rclone.conf"
2023/08/01 09:04:15 DEBUG : Creating backend with remote "/mnt/dropbox/"
2023/08/01 09:04:15 DEBUG : fs cache: renaming cache item "/mnt/dropbox/" to be canonical "/mnt/dropbox"
2023/08/01 09:04:15 NOTICE: bisync is EXPERIMENTAL. Don't use in production!
2023/08/01 09:04:15 INFO  : Synching Path1 "dropbox:/" with Path2 "/mnt/dropbox/"
2023/08/01 09:04:15 INFO  : Path1 checking for diffs
2023/08/01 09:04:23 INFO  : Path2 checking for diffs
2023/08/01 09:04:35 INFO  : No changes found
2023/08/01 09:04:35 INFO  : Updating listings
2023/08/01 09:04:35 INFO  : Removing empty directories
2023/08/01 09:04:43 NOTICE: .stfolder: Skipped remove directory as --dry-run is set
2023/08/01 09:04:43 INFO  : Bisync successful
2023/08/01 09:04:43 NOTICE: 
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Deleted:                0 (files), 1 (dirs)
Elapsed time:        28.3s

2023/08/01 09:04:43 DEBUG : 7 go routines active
2023/08/01 09:04:43 INFO  : Dropbox root '': Committing uploads - please wait...

I understand that the log should say that it does not act on .stfolder because it is filtered, but instead it says that it does not delete it because it is running with --dry-run. If I run rclone without --dry-run it deletes the directory.

It is not a bug but your mistake. You do not exclude directories but files.

To see how your rules are interpreted you can use --dump filters flag and some basic knowledge of regular expressions:

$ rclone bisync src dst --remove-empty-dirs --exclude .stfolder -vv --dump filters --dry-run
--- start filters ---
--- File filter rules ---
- (^|/)\.stfolder$
--- Directory filter rules ---
--- end filters ---
...

To exclude .stfolder directory and all its content you have to use:

$ rclone bisync src dst --remove-empty-dirs --exclude "/.stfolder/**" -vv --dump filters --dry-run
--- start filters ---
--- File filter rules ---
- ^\.stfolder/.*$
--- Directory filter rules ---
- ^\.stfolder/.*$
--- end filters ---
...

To exclude this directory only in root:
--exclude "/.stfolder/**"

In any sub directory
--exclude ".stfolder/**"

Here are all filtering details.

1 Like

Many many thanks. I already figured I was doing something wrong.

With your explanation, the truth is that everything makes sense. I will keep it in mind now and in the future.

Thanks again.

1 Like

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