#!/usr/bin/env python3
import os, collections, re
for root in ["/home/mantapman/.openclaw/media/inbound",
             "/home/mantapman/.openclaw/workspace-atun.legacy-20260912/openclaw-img"]:
    if not os.path.isdir(root):
        continue
    c = collections.Counter()
    for f in os.listdir(root):
        if f.lower().endswith((".jpg", ".jpeg", ".png", ".webp")):
            base = re.sub(r"---.*$", "", f)
            base = re.sub(r"[\d_]+$", "", base) if not re.match(r"^\d", base) else base
            key = re.sub(r"[\d]+", "#", base)[:40]
            c[key] += 1
    print(f"\n== {root}: {sum(c.values())} gambar")
    for k, v in c.most_common(40):
        print(f"   {v:4d}  {k}")
