Is it possible to list only the folders in a bucket using the gsutil
tool?
I can't see anything listed here.
For example, I'd like to list only the folders in this bucket:
You cannot create folders with gsutil as gsutil does not support it (workaround see below). However, it is supported via: UI in browser. write your own GCS client (we have written our own custom client which can create folders)
List the objects in a bucket. In the Google Cloud console, go to the Cloud Storage Buckets page. In the bucket list, click on the name of the bucket whose contents you want to view. Optionally, use filtering to narrow the results in your list.
"gcloud" can create and manage Google Cloud resources while "gsutil" cannot do so. "gsutil" can manipulate buckets, bucket's objects and bucket ACLs on GCS(Google Cloud Storage) while "gcloud" cannot do so.
gsutil uses the prefix gs:// to indicate a resource in Cloud Storage: gs:// BUCKET_NAME / OBJECT_NAME. In addition to specifying exact resources, gsutil supports the use of wildcards in your commands.
Folders don't actually exist. gsutil and the Storage Browser do some magic under the covers to give the impression that folders exist.
You could filter your gsutil results to only show results that end with a forward slash but this may not show all the "folders". It will only show "folders" that were manually created (i.e., not implicitly exist because an object name contains slashes):
gsutil ls gs://bucket/ | grep -e "/$"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With