I already have a Jython script. I don't want to call BASH script in the middle of Python script. Your example is "How to delete folder and its content in a AWS bucket using boto3". I don't want to delete folder. Thank you, Dmitriy Burtsev
import boto def delete_s3_recursive(bucketname, keyprefix): s3 = boto_connect_s3() bucket = s3.get_bucket(bucketname,validate=False) bucketListResultSet = bucket.list(prefix=keyprefix) return bucket.delete_keys([key.name for key in bucketListResultSet])
Given the two parameters, bucketname and keyprefix (the filename mask for targeted files), this should do what you are hoping. Bear in mind your credentials must support the activity for the given bucket/files.