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

0 votes
Jul 3, 2019 in AWS by anonymous
4,591 views
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

Unziiping a tar.gz file in aws s3 bucket and upload it back to s3 using lambda

Hi@khyati, You can do your task using lambda. ...READ MORE

answered Dec 3, 2020 in AWS by MD
• 95,460 points
18,813 views
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,170 points
19,887 views
0 votes
1 answer
+1 vote
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP