--delete-empty-src-dirs flag not working

$ rclone version
rclone v1.49.5

  • os/arch: darwin/amd64
  • go version: go1.12.10

$ echo "This is a test" > /tmp/xyz/foo.txt
$ ls -l /tmp/xyz/
total 8
-rw-r--r-- 1 greg wheel 15 Oct 10 21:04 foo.txt

$ rclone move "/tmp/xyz" "minio-123:greg/tmp/xyz" --log-level DEBUG --config=rclone.conf --delete-empty-src-dirs
2019/10/10 21:05:50 DEBUG : rclone: Version "v1.49.5" starting with parameters ["rclone" "move" "/tmp/xyz" "minio-123:greg/tmp/xyz" "--log-level" "DEBUG" "--config=rclone.conf" "--delete-empty-src-dirs"]
2019/10/10 21:05:50 DEBUG : Using config file from "rclone.conf"
2019/10/10 21:05:50 INFO : S3 bucket greg path tmp/xyz: Waiting for checks to finish
2019/10/10 21:05:50 INFO : S3 bucket greg path tmp/xyz: Waiting for transfers to finish
2019/10/10 21:05:50 INFO : S3 bucket greg path tmp/xyz: Bucket "greg" created with ACL "private"
2019/10/10 21:05:50 DEBUG : foo.txt: MD5 = ff22941336956098ae9a564289d1bf1b OK
2019/10/10 21:05:50 INFO : foo.txt: Copied (new)
2019/10/10 21:05:50 INFO : foo.txt: Deleted
2019/10/10 21:05:50 INFO :
Transferred: 15 / 15 Bytes, 100%, 244 Bytes/s, ETA 0s
Errors: 0
Checks: 2 / 2, 100%
Transferred: 1 / 1, 100%
Elapsed time: 0s

2019/10/10 21:05:50 DEBUG : 6 go routines active
2019/10/10 21:05:50 DEBUG : rclone: Version "v1.49.5" finishing with parameters ["rclone" "move" "/tmp/xyz" "minio-123:greg/tmp/xyz" "--log-level" "DEBUG" "--config=rclone.conf" "--delete-empty-src-dirs"]

$ ls /tmp/xyz
$ ls -l /tmp/
total 8
...
drwxr-xr-x 2 greg wheel 64 Oct 10 21:05 xyz

In other words, it leaves an empty directory /tmp/xyz after the 'move' completes even though I am using the --delete-empty-src-dirs flag. I am trying to understand why
Thanks in advance

--delete-empty-src-dirs doesn't delete the root directory, it deletes empty directoryies under the root directory.

$ tree src
src
├── dir
│   └── potato.txt
└── file.txt

1 directory, 2 files

$ rclone move --delete-empty-src-dirs --disable DirMove src src2 -vv
2019/10/11 07:35:51 DEBUG : rclone: Version "v1.49.5-200-g2549105d-fix-dropbox-nil-pointer-beta" starting with parameters ["rclone" "move" "--delete-empty-src-dirs" "--disable" "DirMove" "src" "src2" "-vv"]
2019/10/11 07:35:51 DEBUG : Using config file from "/home/ncw/.rclone.conf"
2019/10/11 07:35:51 DEBUG : Reset feature "DirMove"
2019/10/11 07:35:51 DEBUG : Reset feature "DirMove"
2019/10/11 07:35:51 INFO  : file.txt: Moved (server side)
2019/10/11 07:35:51 INFO  : Local file system at /tmp/src2: Waiting for checks to finish
2019/10/11 07:35:51 INFO  : Local file system at /tmp/src2: Waiting for transfers to finish
2019/10/11 07:35:51 INFO  : dir/potato.txt: Moved (server side)
2019/10/11 07:35:51 DEBUG : dir: Removing directory
2019/10/11 07:35:51 DEBUG : Local file system at /tmp/src: deleted 1 directories
2019/10/11 07:35:51 INFO  : 
Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 2 / 2, 100%
Transferred:            0 / 0, -
Elapsed time:          0s

2019/10/11 07:35:51 DEBUG : 4 go routines active
2019/10/11 07:35:51 DEBUG : rclone: Version "v1.49.5-200-g2549105d-fix-dropbox-nil-pointer-beta" finishing with parameters ["rclone" "move" "--delete-empty-src-dirs" "--disable" "DirMove" "src" "src2" "-vv"]

$ tree src
src

0 directories, 0 files

$ tree src2
src2
├── dir
│   └── potato.txt
└── file.txt

1 directory, 2 files
$ 

Thank you for the response.
Seems a bit counter intuitive, if you ask me. The usual semantics of 'move' operation includes deleting the source root dir. See Unix 'mv', Windows 'move' , Java Files.move(), etc etc

I think that is what It did when we first implemented it but we changed it because a very common workflow is to move things into a directory to be uploaded and it was annoying to have that directory disappear.

The way it is currently is definitely needed for many workflows, but I kind of agree with bayareagreg that it is perhaps not what you expect and it can be annoying the other way around in some cases.

It might be worth an optional flag, assuming that it would be a fairly trivial implementation and doesn't break anything else.

A --delete-root flag would be easy enough... Or just put an rmdir in the script.

That would work for me.
Thanks

1 Like

Want to make an issue?

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