5
votes

I need to copy content inside a AWS S3 bucket root folder to another folder inside root.

I want copy all files in root (textfile1.txt etc) except other folders (folder1,folder2) in to the folder3.

What would be the aws s3 copy command for it?

/
folder1
folder2
textfile1.txt
textfile2.txt
--many other text files
folder3
1
So you want to copy *.txt files into folder3?helloV

1 Answers

14
votes

This command will copy all files from the root of the bucket, but will not copy any sub-folders:

aws s3 cp s3://my-bucket s3://my-bucket/destination --recursive --exclude "*/*"
  • --recursive causes it to copy all files and folders
  • --exclude "*/*" prevents it from copying any objects with a / in the key (which is used to indicate a sub-folder)

See also: