Deletion of folders with the same ending in the folder name

I have a few subfolders with the same change in the name, e.g.

/xxx.tmp
/yyy.tmp
/zzz.tmp

I managed to delete the content of these sub-folders with:

rclone delete GDrive_enc:EX52/Proxmox/dump --include .tmp/* -v

But how do I delete the actual folders?

Here's what I've tried:

rclone delete GDrive_enc:EX52/Proxmox/dump --filter "+ /.tmp" -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump --include .tmp -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump --include /
.tmp -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump --include /**.tmp -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump/
.tmp -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump --include /.tmp/ -v --dry-run
rclone delete GDrive_enc:EX52/Proxmox/dump --include /.tmp -v --dry-run

I think you need to use rclone purge instead of delete if you want to delete the folder and not just its contents.

Thanks for the hint, but that didn't change anything at first.

The problem seems to be that the variable asterisk is not recognized in the folder name, if a fixed text component comes after the variable (here: abcd.tmp, efg.tmp etc.).

Perhaps it wasn't quite clear either that .tmp is an integral part of the folder name and does not stand for an extension of a file.

To clean a directory and all its subdirs, you'd use purge if you want to use one command.

If you want to use delete, you'd have to use rmdirs after it and use two commands.

If you are having an issue with a filter, I'd use rclone ls and test / validate and fix the filter from there. If you share the directory listing, we can help with the filters.

This is an overview of the directories, of which there are dozens that should be deleted:

The easiest way of doing this is to run rclone rmdirs after the delete. This will recursively delete empty directories.

1 Like

I wasn't even aware that the rmdir command, known from Linux, can be used to delete empty directories under rclone with rmdirs.

Thank you very much, that was exactly what I was looking for.

1 Like

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