MT467
MT467

Reputation: 698

gsutil to copy all files and create a subdirectory

I have 4 files xxxxx.xlsx in this directory:

/var/tmp/dagxxxxx/2019-08-10/xxxxx.xlsx

I want to copy them over to:

gs://reports_dev/2019

Using gsutil cp -r the final gcs path should be like(with all 4 files):

gs://reports_dev/2019/2019-08-10/xxxxx.xlsx

I tried different combination of cp and -r like:

gsutil cp -r /var/tmp/dagxxxxx/2019-08-10/** gs://reports_dev/2019

but couldn't get the desired path in gcs.

Upvotes: 2

Views: 4448

Answers (1)

Guanaco Devs
Guanaco Devs

Reputation: 1914

Remove the trailing Asterisks, -r already means recursive, this should work:

gsutil cp -r /var/tmp/dagxxxxx/2019-08-10/ gs://reports_dev/2019

If you append a forward slash / to your source, it will copy the folder to your destination, if you don't, it will copy the Content of your source to your destination.

Upvotes: 4

Related Questions