The way I have been using is to transform the Collection into a List and query the length:
s3 = boto3.resource(\'s3\')
bucket = s3.Bucket(\'my_bucket\')
size = l
For my use case, I just needed to know whether the folder is empty or not.
s3 = boto3.client('s3')
response = s3.list_objects(
Bucket='your-bucket',
Prefix='path/to/your/folder/',
)
print(len(response['Contents']))
This was enough to know whether the folder is empty. Note that a folder, if manually created in the S3 console, can count as a resource itself. In this case, if the length shown above is greater than 1, then the S3 "folder" is empty.