0

I wish to copy all files except a certain directory or directories (or files) from my GCS bucket to my local directory. Is there anyway I can do the same?

For example: My GCS bucket named so-bucket has three folders dir1, dir2, dir3, file1 and file2. I want to copy all the files and directories except dir3 from the bucket to my local directory.

Usually I would do gsutil -m cp -r gs://so-bucket/* . and then delete the dir3 folder.

1 Answer 1

5

You can use gsutil rsync command, with -x option to exclude some objects. Something like :

gsutil -m rsync -r -x '^dir3/*' gs://so-bucket .

should retrieve all objects located on the bucket, except objects beginning with dir3 (files not located in dir3 directory in your example).

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