4

I would like to copy files matching a file name pattern from my machine to an AWS S3 bucket using AWS CLI. Using the standard unix file name wildcards does not work:

$ aws s3 cp *.csv s3://wesam-data/

Unknown options: file1.csv,file2.csv,file3.csv,s3://wesam-data/

I followed this SO answer addressing a similar problem that advises using the --exclude and --include filters as explained here as shown below without success.

$ aws s3 cp . s3://wesam-data/ --exclude "*" --include "*.csv"
Sam
  • 11,799
  • 9
  • 49
  • 68
  • 1
    Yes, unfortunately `aws s3 cp` does not work the same way as Linux/Mac `cp` where you can happily do `cp filea fileb filec somefolder/`. – jarmod Dec 19 '19 at 14:31

1 Answers1

6

Solution

$ aws s3 cp . s3://wesam-data/ --exclude "*" --include "*.csv" --recursive

Explanation

It turns out that I have to use the --recursive flag with the --include & --exclude flags since this is a multi-file operation.

The following commands are single file/object operations if no --recursive flag is provided.

  • cp
  • mv
  • rm
Sam
  • 11,799
  • 9
  • 49
  • 68