AWS S3 PS script to get files less than 7 days and delete it

Hi Team,
We have S3 bucket for which we need to set up retention policy of 7 days for it folder and subfolders. I wrote the below code however it gives me folders and files both. I need just files (like we use -files paramater in GCI command).

foreach ($o in $outbox)
Get-S3Object -BucketName $bucketname -AccessKey $accesskey -SecretKey $secretkey -KeyPrefix $o | where LastModified -LT (Get-Date).AddDays(-7)

How can i get only files from s3 folders.

You’d have to see what you can filter on to determine if it is a file. The examples I see indicate the Get-S3Object returns files, like this blog: PowerShell works for Amazon AWS S3 too! | Microsoft Docs

Try adding a | Select * or Get-Member to see all of the properties that Get-S3Object returns so you can build a Where filter