-1

I need some help with creating a script(python, bash) that I can start it on my windows. Basically What I need is that the script will go to my CSV excel file, take the files names that I want to delete from S3 bucket, and go to my aws s3 and remove them. And show output what or how many files have been deleted and if there were any errors.

Thanks

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
hightest
  • 395
  • 5
  • 15
  • How often do you intend to run this script? Is it a one-off, or something you will do often? What have you written so far? Have you written something to extract data from Excel? Have you written something to delete files from S3? What step is giving you problems at the moment? – John Rotenstein Mar 10 '19 at 20:06
  • I will need to run this script when is needed can be once in a week can be once in 2-3 days or every day. For now, I got this script to show me all the lines I got in my file: filename='/tmp/list' n=1 while read line; do # reading each line echo "Line No. $n : $line" n=$((n+1)) done < $filename And i got 2 commands that remove files from s3 bucket for example: aws s3 rm s3://Bucket-Name/1.bmp aws s3 rm s3://Name_Of_The_Bucket/ --recursive --exclude "*" --include "File_Name" --include "File_name" now I need line that connect to my aws account with aws configure and remove files. – hightest Mar 11 '19 at 08:25

1 Answers1

0

Frankly, you have two choices...

The easy option is to create a formula that generates the delete commands, then copy & paste the commands into the Command Prompt. For example, if the file names are in Column A, then put this in Column B:

="aws s3 rm s3://my-bucket/"&A1

Use Copy Down the formula to generate the commands. Then, copy the commands, paste them in the Command Prompt and you're one!

The harder option is to write a program that does as you said -- reads an excel file and calls the AWS API to delete the files. I'd recommend using either Read Excel sheet in Powershell or a Python script. This is a better option if you need to run it frequently, but takes more effort.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470