Download the folders from S3 Bucket

import boto3
import os 
def downloadDirectoryFroms3(remoteDirectoryName):
    aws_access_key_id = ""
    aws_secret_access_key = ""
    BUCKET_NAME = ""
    s3_resource = boto3.resource('s3', aws_access_key_id=aws_access_key_id,
                                 aws_secret_access_key=aws_secret_access_key)
#     s3_resource = boto3.resource('s3')
    bucket = s3_resource.Bucket(BUCKET_NAME) 
    for obj in bucket.objects.filter(Prefix = remoteDirectoryName):
#         print(obj.key,os.path.dirname(obj.key))
        if not os.path.exists("/{}".format(os.path.dirname(obj.key))):
            os.makedirs("/{}".format(os.path.dirname(obj.key)))
        bucket.download_file(obj.key, "/{}".format(obj.key)) # save to same path


FILE_NAMES = [

            ]
for folder_name in FILE_NAMES:
    print(folder_name)
    downloadDirectoryFroms3(folder_name)