4

Previously gsutil appeared to not upload hidden files. Now hidden files cannot be prevented from upload. Using the -x command with either .*/\\..* or .*/[.].* still uploads both hidden files and directories. This is with a local directory up to a bucket.

Is there a different expression that is required?

1
  • If you think one of the posts answers your question, feel free to mark it as the solution.
    – Dave Liu
    Commented Dec 20, 2021 at 19:21

3 Answers 3

2

The -x exclude option should work:

gsutil rsync -x '\..*|./[.].*$' source-dir gs://your-bucket

You can learn more about it from the [official documentation].

4
  • 1
    That correctly handled the top level hidden folders. The final solution is '\..*|./[.].*$' Commented Nov 16, 2015 at 16:08
  • 1
    \..*|./[.].*$ is not working for me with .DS_Store files.
    – David T
    Commented Jan 14, 2016 at 19:35
  • Doesn't work for me with env/.Python
    – Dave Liu
    Commented Dec 20, 2021 at 19:23
  • Oh, had to escape /
    – Dave Liu
    Commented Dec 20, 2021 at 19:25
1

This works for both hidden files and directories, at any spot in the path:

gsutil rsync -x '.*/\..*|^\..*' source dest

The other answer didn't work for me.

0

As the regexp is not tied to the edges of the string, .*'s at the beginning and at the end are not necessary, plus we can use grouping to simplify (sic!) a bit:

gsutil rsync -x '(^|/)\.' source dest

Where \. is the dot itself and (^|/) states that the dot should follow either the beginning of file name (^) or a / - a dot file in a subfolder.

Not the answer you're looking for? Browse other questions tagged or ask your own question.