Vlad Z
Vlad Z

Reputation: 13

Recursively changing file extensions on Amazon S3

I have a large S3 bucket with a nested "folder" structure containing among other things .JPG and .jpg files (uppercase and lowercase extensions).

So I need do change .JPG files to lowercase extension.

What is the best way to do it?

Upvotes: 1

Views: 2187

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269480

You would need to Copy the old objects to the new name, then Delete the old objects.

If it is a one-off, I would create a spreadsheet list of Keys, then write a formula that uses the aws s3 mv command. This performs both a Copy and a Delete:

aws s3 mv s3://bucket/folder/foo.JPG s3://bucket/folder/foo.jpg

Then, copy all those commands and paste them into the Command Prompt / Terminal to trigger the rename.

For a large (over 1000) number of objects, I'd suggest doing it via a Python script that does the Copy and Delete.

Upvotes: 1

Related Questions