简体   繁体   中英

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?

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}

You could use a script like:

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

对我来说,有效的在下面

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM