
I tested using gio trash FILENAME on the command line, and it works just like I'd selected the file in the file browser and clicked the DEL button: the file is moved to the desktop's Trash folder. f, -force Ignore nonexistent files, never prompt Commanding gio help trash outputs: Usage: Neither of those are found by default on Ubuntu 18.04, but the command gio is. The previous answers mention commands trash-cli and rmtrash. While those discussions have a point, I believe there’s still a niche for my request.) (As an aside, there have been endless discussions whether this approach is justified, rather than using frequent backups and VCS. Are there any existing solutions for this which don’t rely on a trash system from a graphical shell? Partial solutions for this exist, but the “restore” action in particular isn’t trivial. Furthermore, it’d be nice if the trash was automatically emptied on reboot (or a similar mechanism to prevent endless growth). A single mv ~/.trash is a first step, but ideally this should also handle trashing several files of the same name without overwriting older trashed files, and allow to restore files to their original location with a simple command (a kind of “undo”). My command posted above is more of a workaround, simply enumerating and deleting files while bypassing the drive files.Is there a Linux script / application which, instead of deleting files, moves them to a special “trash” location? I’d like this as a replacement for rm (maybe even aliasing the latter there are pros and cons for that).īy “trash” I mean a special folder. So it's definitely not rclone's fault, as the problem is repeatable outside of rclone. It completed with a good response, but all the files remained. I followed Google's instruction set on the developer portal. But, after running the command in my post, I deleted the 98% in about 2 minutes.Įdit: To further clarify my original post, the inability to empty the trash via the cleanup/delete API command is not rclone's fault. It only removed about 2% of my trash after a week. I used the command, and it kinda worked, but even Nick (rclone's developer) has commented on other posts on this forum about how no-one really knows what's going on or why it sometimes doesn't work.Īs mentioned, I do use it, but after running the command on cron jobs for almost a week, my drive trash was still massive, with thousands of files. The cleanup command was implemented into rclone to help. I hope this helps someone who needs to empty their trash. verbose=2: prints a verbose output of the operation, useful for keeping a visual eye on the progressĪfter running this, I empty 3tb of data that was just junk. It uses less transactions (good for API usage) but it uses a little more memory. fast-list: this build a list of the files in memory. We obviously want to empty the trash, so the false flag will bypass this default option. By default, a google drive remote will send deleted files to the google drive trash. drive-use-trash=false: Also critical, as it doesn't use the drive trash when you delete the files. It interacts with only the files in the trash in the same folder structure as it was when it was deleted from the drive. drive-trashed-only: This is absolutely crucial. Gdrive-root: a custom remote that has it's own client/key and does not have a folder id (runs on the root of the google drive)


Rclone delete gdrive-root: -drive-trashed-only -drive-use-trash=false -verbose=2 -fast-list

Here's the command to run (add -dry-run to the first run to verify everything first so you know what you're deleting) It's not the fault of rclone, it's Google's bad implementation of a simple delete idea.īut, I did find a solution that worked for me (be careful, however, as you can use a lot of API requests and get rate limited.) Use your own secret/key and I would recommend using a separate secret/key/project from the one you use for your production rclone setup. For example, I tried the DELETE command directly in google's developer portal (link above) and the trash did not empty. I used the command, and it kinda worked, but even Nick (rclone's developer) has commented on other posts on this forum about how no-one really knows what's going on or why it sometimes doesn't work. It basically uses the drive DELETE api command, which can be demoed here: Google's UI method to emptying trash is awful and extremely lacking, especially for the kind of people who use rclone. Just wanted to share my experience with emptying my google drive trash.
