GoogleCloudPlatform / GoogleCloudPlatform/gsutil
Replicate directory structure in bucket using gsutil cp with wildcards
- Dominant language
- Python
- Stars
- 918
- Forks
- 335
- PR merge metrics
- No merged PRs in 30d
Description
This is essentially a feature request for the [question](https://stackoverflow.com/questions/43278995/replicate-directory-structure-in-bucket-using-gsutil-cp-with-wildcards) I posted on stackoverflow.
Let's say I have the following folders in my bucket:
```
2011/03/11/a/b/c
2012/04/11/c
2013/04/11/f
```
When I copy directories from my bucket using:
```bash
$ gsutil cp -r gs://my-bycket .
```
it creates the folders (`2011/03/11/a/b/c` etc) on my local harddrive and then place the files under these folders (which is what I want). The problem is that I don't want to copy ALL files in these folders so I use a wildcard like this instead:
```bash
gsutil cp -r "gs://my-bucket/**/name-????.gz" .
```
gsutil starts copying all the files correctly but it flattens out the folder structure and place each file directly in my current directory which is not what I want.
I'd like a flag that allows gsutil to create the directory structure for each file when doing this. Would this be feasible?
Contributor guide
Assessment
This issue has not been assessed yet.