-1

Trying to count objects inside every folder inside the bucket (1 layer only)

Here is what i tried:

chcp 65001
Foreach($v in gsutil ls "gs://bucket/*"){
    echo $v (gsutil ls $v).Length
}

It works fine at first, but there are 2 cases that cause errors:

  1. Folders containing "#" sign would cause the error "One or more URLs matched no objects."
  2. Folders containing Chinese Characters (i tried Chinese only) would have encoding issues, causing $v incorrect
ssit
  • 1
  • 1

1 Answers1

0

You are going to need regex. I have never used Powershell but the principle is the same. You can match Chinese characters with regex like this:

Documentation

\p{script=Han}

or

\p{Han}

To match only a # you can do this:

(\#)
Andrew
  • 795
  • 4
  • 18