Empty directory not `rmdir`ing

What is the problem you are having with rclone?

I have just moved a folder onto my local machine for moderation, and I now have an empty directory on my GSuite remote. I have tried to remove this using the rmdir command, but I get the error that the directory is not empty, so I can't remove it. But I have checked the size of the directory, and used the ls command to list the contents, and both come up empty, even when the directory can't be deleted.

What is your rclone version (output from rclone version)

My rclone version is 1.51.0.

Which OS you are using and how many bits (eg Windows 7, 64 bit)

I am on Windows 10 (64 bit)

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

I am using Google Drive

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

rclone rmdir [REDACTED]

A log from the command with the -vv flag

 rclone -vv rmdir [REDACTED]
2020/06/04 14:56:45 DEBUG : rclone: Version "v1.51.0" starting with parameters ["rclone" "-vv" "rmdir" [REDACTED]]
2020/06/04 14:56:45 DEBUG : Using config file from "C:\\Users\\Callum Stewart\\.config\\rclone\\rclone.conf"
2020/06/04 14:56:45 DEBUG : GSuite: Loaded invalid token from config file - ignoring
2020/06/04 14:56:45 DEBUG : Keeping previous permissions for config file: -rw-rw-rw-
2020/06/04 14:56:45 DEBUG : GSuite: Saved new token in config file
2020/06/04 14:56:49 DEBUG : Encrypted drive '[REDACTED]': Removing directory
2020/06/04 14:56:53 DEBUG : : Rmdir: contains file: "lr09nep2ph1l0qv19k6lmgtcl4"
2020/06/04 14:56:53 ERROR : Attempt 1/3 failed with 1 errors and: directory not empty
2020/06/04 14:56:53 DEBUG : Encrypted drive '[REDACTED]': Removing directory
2020/06/04 14:56:54 DEBUG : : Rmdir: contains file: "lr09nep2ph1l0qv19k6lmgtcl4"
2020/06/04 14:56:54 ERROR : Attempt 2/3 failed with 1 errors and: directory not empty
2020/06/04 14:56:54 DEBUG : Encrypted drive '[REDACTED]': Removing directory
2020/06/04 14:56:54 DEBUG : : Rmdir: contains file: "lr09nep2ph1l0qv19k6lmgtcl4"
2020/06/04 14:56:54 ERROR : Attempt 3/3 failed with 1 errors and: directory not empty
2020/06/04 14:56:54 Failed to rmdir: directory not empty

hello,
when you posted you should have been asked some questions.
can you answer those questions?

I have edited my post with the answers. I redacted the path, because it contains information I would rather not share.

you should update to the latest stable, v1.52.0

i think those files are shortcuts, a new feature of gdrive.
https://rclone.org/drive/#shortcuts

Is there a way to get notified when a new version releases, so I'm always in the loop? Also, should I just purge those directories to remove them if that's the case?

new versions are posted as a topic in the forum.
so visit often...

Can I just rclone purge those shortcuts?

i tend to run a little paranoid.

so when it comes to commands like the very scary purge
and how that interacts with a new feature like shortcuts,
i cannot advise you.

@calisro, might be able to comment?

Why do you think they are shortcuts? Do a list on the directory and compare these two results:

rclone lsf --format tspm remote:directory --drive-skip-shortcuts
rclone lsf --format tspm remote:directory

Be careful with shortcuts. Here is the way they are supposed to work. I also advise you to upgrade to 1.52.

For shortcuts pointing to files:

  • When listing a file shortcut appears as the destination file.
  • When downloading the contents of the destination file is downloaded.
  • When updating shortcut file with a non shortcut file, the shortcut is removed then a new file is uploaded in place of the shortcut.
  • When server side moving (renaming) the shortcut is renamed, not the destination file.
  • When server side copying the shortcut is copied, not the contents of the shortcut.
  • When deleting the shortcut is deleted not the linked file.
  • When setting the modification time, the modification time of the linked file will be set.

For shortcuts pointing to folders:

  • When listing the shortcut appears as a folder and that folder will contain the contents of the linked folder appear (including any sub folders)
  • When downloading the contents of the linked folder and sub contents are downloaded
  • When uploading to a shortcut folder the file will be placed in the linked folder
  • When server side moving (renaming) the shortcut is renamed, not the destination folder
  • When server side copying the contents of the linked folder is copied, not the shortcut.
  • When deleting with rclone rmdir or rclone purge the shortcut is deleted not the linked folder.
  • NB When deleting with rclone remove or rclone mount the contents of the linked folder will be deleted.

Also if you're acting on a crypt remote, you could have non-crypted files in the folder that won't be list-able within the crypt.

This what I got with both the drive-skip-shortcuts flag and without:

 rclone lsf --format tspm [REDACTED]
2020-03-23 16:56:48;-1;1/;inode/directory
2020-03-23 15:43:04;-1;10/;inode/directory
2020-03-23 15:53:38;-1;11/;inode/directory
2020-03-23 15:37:36;-1;12/;inode/directory
2020-03-23 15:46:58;-1;13/;inode/directory
2020-03-23 15:40:14;-1;14/;inode/directory
2020-03-23 15:58:47;-1;15/;inode/directory
2020-03-23 17:06:04;-1;16/;inode/directory
2020-03-23 16:02:27;-1;17/;inode/directory
2020-03-23 16:05:45;-1;18/;inode/directory
2020-03-23 16:13:15;-1;19/;inode/directory
2020-03-23 16:09:47;-1;2/;inode/directory
2020-03-23 16:21:01;-1;20/;inode/directory
2020-03-23 16:16:37;-1;21/;inode/directory
2020-03-23 17:56:19;-1;22/;inode/directory
2020-03-23 16:30:15;-1;23/;inode/directory
2020-03-23 16:24:29;-1;24/;inode/directory
2020-03-23 16:33:39;-1;25/;inode/directory
2020-03-23 16:37:25;-1;26/;inode/directory
2020-03-23 16:41:33;-1;27/;inode/directory
2020-03-23 16:44:47;-1;28/;inode/directory
2020-03-23 17:01:56;-1;3/;inode/directory
2020-03-23 17:52:48;-1;4/;inode/directory
2020-03-23 17:48:36;-1;5/;inode/directory
2020-03-23 17:33:46;-1;6/;inode/directory
2020-03-23 17:38:07;-1;7/;inode/directory
2020-03-23 17:44:56;-1;8/;inode/directory
2020-03-23 17:41:25;-1;9/;inode/directory
2020-03-23 17:09:57;-1;crop/;inode/directory

So they are not shortcuts but you have directories in the directories because if they were shortcuts, you would have seen a difference between the two commands. So it isn't empty.

If all that is in that remote is empty directories and you want to clear them out recursively, you can run:

rclone rmdirs <remote>:<directory>

If there are files you'd need to delete them. You can add the -R flag to the lsf to recursively list them.

But I don't understand why it says it's empty when I size that folder

directories are zero bytes. They are just metadata.

@dell-rob:~$ rclone mkdir robgs:test
@dell-rob:~$ rclone mkdir robgs:test/test
@dell-rob:~$ rclone mkdir robgs:test/test/test
@dell-rob:~$ rclone -vv rmdir robgs:test
2020/06/04 13:23:16 DEBUG : rclone: Version "v1.52.0-001-g1cceadaf-beta" starting with parameters ["rclone" "-vv" "rmdir" "robgs:test"]
2020/06/04 13:23:16 DEBUG : Using config file from "/home/calistri/.rclone.conf"
2020/06/04 13:23:16 DEBUG : Google drive root 'test': Removing directory
2020/06/04 13:23:17 DEBUG : : Rmdir: contains file: "test"
2020/06/04 13:23:17 ERROR : Attempt 1/3 failed with 1 errors and: directory not empty
2020/06/04 13:23:17 DEBUG : Google drive root 'test': Removing directory
2020/06/04 13:23:17 DEBUG : : Rmdir: contains file: "test"
2020/06/04 13:23:17 ERROR : Attempt 2/3 failed with 1 errors and: directory not empty
2020/06/04 13:23:17 DEBUG : Google drive root 'test': Removing directory
2020/06/04 13:23:17 DEBUG : : Rmdir: contains file: "test"
2020/06/04 13:23:17 ERROR : Attempt 3/3 failed with 1 errors and: directory not empty
2020/06/04 13:23:17 DEBUG : 4 go routines active
2020/06/04 13:23:17 Failed to rmdir: directory not empty
@dell-rob:~$ rclone size  robgs:test
Total objects: 0
Total size: 0 Bytes (0 Bytes)

Can I delete them safely with purge?

Stay away from purge unless its required. If they are empty dirs just run

rclone rmdirs remote:location

If the total size is zero, they're all empty, right?

Looks like it. yes. rmdirs will just not delete them if they have something in them besides empty directories.

So all those metadata directories are fine to remove using rmdirs without messing anything up? Just want to check in case I mess something up.

I don't know what your use case is for having them there. But if you want to delete them, then rmdirs would do it. purge would also but I just am very careful with that command because a simple typo can be bad.

I'm not sure why they're there in the first place, or what I did that generated them all. So if they're safe to remove so that I don't have extraneous folders in my remote, I'll do so