Seeker90
Seeker90

Reputation: 895

Create a folder in AWS S3 bucket with current date

I want to create a directory with current date as the directory name and move files created on my local file system into this new directory.

The goal is to transfer files created everyday in local system into S3 with current date as directory name.

aws s3 cp --recursive "local_folder" s3://bucket/directory/ 

How can I add the current date to the directory name?

Upvotes: 2

Views: 8445

Answers (3)

danD
danD

Reputation: 736

For me the one which worked is below

aws s3 cp filename s3://bucketName/data/date=$(date '+%Y-%m-%d')/

Upvotes: 0

Luis Guilherme Russi
Luis Guilherme Russi

Reputation: 21

If you are going to use a script, I'd prefer to do:

DATE=$(date '+%Y%m%d')
BUCKET="bucket-name"
aws s3 cp --recursive "local_folder" s3://${BUCKET}/${DATE}

Upvotes: 2

John Rotenstein
John Rotenstein

Reputation: 269931

You could use a script like:

DATE=`date '+%Y-%m-%d'`
echo aws s3 cp --recursive "local_folder" s3://bucket/$DATE/ 

Upvotes: 1

Related Questions