title: How can I convince AWS CLI sync to exclude any file matching a directory pattern?
body: <p>The use case is I want to exclude certain data from going up to S3. The files could be anywhere within the file hierarchy, but if they are contained anywhere below a directory named <code>foobar</code> I don't want them copied over.</p>
  
  <p>For example:</p>
  
  <pre><code>/my-data/20150806-1600/foobar/blah.csv  # Exclude
  /my-data/20150806-1600/dingbat/blah.csv # Include
  /my-data/clients/foobar/README.txt      # Exclude
  
  $ /usr/local/bin/aws --version
  aws-cli/1.11.117 Python/2.7.6 Linux/3.13.0-92-generic botocore/1.5.80
  </code></pre>
  
  <p>Alas ...</p>
  
  <pre><code>/usr/local/bin/aws s3 sync /my-data/ s3://my-bucket/my-data/ --exclude '*/foobar/*' --exclude '*/foobaz/*' --delete
  </code></pre>
  
  <p>The files still upload. I have tried changing the exclude pattern(s) to <code>foobar/*</code> and <code>*foobar*</code> but in every case, files matching a parent directory with <code>foobar</code> in the path still get uploaded.</p>