Delete objects from R2 bucket older than a date?

Hi, is there a way to delete all objects in a R2 bucket that are older than a certain date or time? Either using aws cli, or boto3 in Python.

Thanks :slight_smile:

You should be able to use boto3 to delete all objects older than a date. You can configure S3 with this guide

Thanks.

Can aws cli do it too?

You can config aws cli for R2

I’ve configured aws cli for R2 and managed to delete all objects in the bucket.

How can I use aws cli to delete objects in the bucket that is older than a certain datetime?

This is more of an AWS cli question and not directly related to Cloudflare. A quick google found this