When ever a file is added in s3 bucket, should it be renamed using timestamp?

0 votes
Jul 2, 2019 in AWS by anonymous
You want the filename to have the timestamp or add a timestamp to the file's metadata?
my files doesn't have timestamp.
when a file is uploaded to S3 bucket, it needs to be renamed with a timestamp added at the end.

You can rename it on #bash and then upload it on s3

for f in test/*; do TIMESTAMP=$(date +%s); FILENAME=${f%.*}; EXTENSION=${f##*.}; NEWNAME="$FILENAME-$TIMESTAMP.$EXTENSION"; mv $f $NEWNAME; done
Thanks for the command.
Mycase is when ever a new file is added to s3 bucket it should rename with timestamp.

With the above command I need to implement it each time when a file is added.
Yeah above command is the manual way of doing this. As far as I remember, you cannot change the filename during the upload. You can change it either after uploading or before uploading the file to the bucket.

What is your motive behind adding the filename with timestamp?
the src and dst files will be in the same bucket.

so I want to add a timestamp

can we do with lambda ?
You can create a CI/CD pipeline to upload files on S3 bucket and add the script in the pipeline to add the timestamp. This will automate the process.
Can we use nohup and the above command?
How exactly are you thinking of using nohup?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer

How to download the latest file in a S3 bucket using AWS CLI?

You can use the below command $ aws ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,150 points
0 votes
2 answers

How to skip headers when reading a CSV file in S3 and creating a table in AWS Athena?

Thanks for the answer. This should be clear ...READ MORE

answered Aug 14, 2019 in AWS by athenauserz
–1 vote
1 answer

How to read a csv file stored in Amazon S3 using csv.DictReader

The code would be something like this: import ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,600 points
0 votes
1 answer
+1 vote
2 answers