Allow "rclone delete" to delete oldest files until a max size has been reached

I use rclone to upload my CCTV footage.
Now the Partition is 50 GB so i can have a lot of videos to upload.

On the other hand i have 35 GB in Mega and need to keep it under a max value of etc. 30 GB to insure i can upload the newest recordings.

I propose that "rclone delete" gets a so called filter where one could tell it that there may max be used 30GB og space and to delete the oldest files first until the limit has been reached.

rclone delete Remote:/CCTV --max-allowed-usage 30g --delete-oldest-first

I really hope this could be implemented since the camera is recording on motion so i cant predict that it will take etc. 7 days or 2 weeks to use 30 GB and then delete oldest based on age.

I need to delete oldest files based on the space in use in the current folder.

Hope this can be implemented and thank you for reading.

Best Regards,

hello and welcome to the forum,

that is an interesting flag.

you should be able to write a script for that.
to get the total amount of storage used
rclone about

Hi thank you for your reply.
I must say i have no experience in scripting and no idea of where to begin.

I do understand that i can run etc.

rclone size Remote:/CCTV

And get a size like

Total objects: 258
Total size: 20.106 GiByte (21588537743 bytes)

Even if i were able to write a script.
I do not understand how that would make it possible to delete the oldest files first on "Remote:" with the current "rclone delete" command and filters.
And mix that with stopping when its reached the max size. Which is related to the "rclone size" command.

wouldn't it be a useful future to have in "rclone" to be able to delete oldest files based on a max size in th e "rclone delete" command.
If its first implemented i would believe people could make good use of that.

Are the files names so they will sort by age? And are they all roughly the same size?

If so you could do something like this, assuming you want to delete all but the last 100 files

rclone lsf Remote:/CCTV | sort -r | tail -n +100 > to-delete
rclone delete --files-from to-delete Remote:/CCTV

rclone lsf... lists the files, sort -r sorts them in reverse aphabetical so the newest are first, tail -n +100 shows any lines remaining after the first 100.

Thank you this worked and it deleted the excessive files.

Though i am having a problem that it only moves the files to recycle bin and doesn't delete it completely.

I tried adding the flag --mega-dard-delete but it didnt completely delete it. just ended up in recycle bin.

This is the command in use

rclone delete --files-from to-delete --mega-hard-delete Remote:/CCTV/


That is the right flag and I'd really expect it to work...

You can use rclone cleanup to clear the trash.

This worked perfectly deleted the files in recycle bin.

Thank you for the help i believe this helped me gain the result i wanted.

1 Like

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