Currently, I have 30 Million files in one folder in an S3 bucket I want to move 7.5 million files from it into 4 folders in an S3 bucket
I tried out with the AWS CLI command but no idea how to mention the number of files in it
aws s3 mv s3://BUCKETNAME/myfolder/ s3://BUCKETNAME/folder1/ --recursive
How can I loop and move only 7.5 million files into each folder?
import boto3
aws_access_key_id = ""
aws_secret_access_key = ""
bucket_from = ""
bucket_to = ""
s3 = boto3.resource(
's3',
aws_access_key_id=aws_access_key_id,
aws_secret_access_key=aws_secret_access_key
)
src = s3.Bucket(bucket_from)
def move_files():
for archive in src.objects.all():
s3.meta.client.copy_object(
ACL='public-read',
Bucket=bucket_to,
CopySource={'Bucket': bucket_from, 'Key': archive.key},
Key=archive.key
)
move_files()
