Counts the number of directories (folders) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting the immediate subdirectories under the bucket (or a given prefix) as well as all nested directories recursively. Uses the KooCLI obsutil-backed hcloud OBS ls -d command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many directories/folders an OBS bucket contains, e.g. for inventory, capacity review or structure checks. Triggers include: "count OBS directories", "OBS directory count", "number of directories in bucket", "OBS folder count", "how many folders in bucket", "OBS目录数量", "查询OBS目录数量", "OBS目录数", "桶目录数量", "目录数量", "文件夹数量", "统计目录", "目录统计".
This skill counts the number of directories (folders) in a Huawei Cloud OBS bucket and returns only the count (a single integer). It is a read-only statistics skill: it never creates, modifies, or deletes buckets, directories, or objects.
hcloud CLI (KooCLI) installed and authenticated — See references/cli-installation-guide.md
obsutil installed — required by the hcloud OBS ls command (bundled with KooCLI or standalone)
OBS credentials configured for obsutil — hcloud OBS ls reads AK/SK/endpoint from the obsutil config file
(.obsutilconfig in the user home directory), which is separate from the KooCLI account credentials
IAM permissions — obs:bucket:ListBucket, obs:object:List — See references/iam-policies.md
OBS credentials are separate. Before running, check whether obsutil credentials are configured:
bash
hcloud OBS ls -s -limit=1
If the output is Please set ak, sk and endpoint in the configuration file! or an InvalidAccessKeyId error,
obsutil credentials are not configured. Ask the user to configure them in their own terminal (never ask the user
to paste AK/SK into the conversation). Provide the following example command:
Example (cn-north-4): hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-north-4.myhuaweicloud.com
Workflow
Confirm the bucket name — ask the user which OBS bucket to inspect (and optionally a subdirectory prefix)
Verify prerequisites — hcloud version, hcloud OBS ls -s -limit=1 to confirm obsutil credentials
Run the count — use the script scripts/count_obs_directories.py (primary) with the appropriate flags
Return the count — the script prints a single integer; relay that integer to the user
Handle errors — if the script fails (e.g. bucket not found, invalid AK/SK, missing credentials), the script
prints a clear Chinese error hint on stderr with configuration guidance; relay that hint to the user
Core Commands
Count Immediate Subdirectories (Primary)
Returns the number of subdirectories directly under the bucket:
The underlying obsutil command the script uses for immediate counts is hcloud OBS ls obs://<bucket_name>/ -d.
The Folder number: N line at the end of the output is the immediate directory count. Prefer the
script commands above; use the raw obsutil command only for manual inspection.