# -*- coding: utf-8 -*-
import os, sys, glob, re
sys.stdout.reconfigure(encoding='utf-8')
ROOT = r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵'
for prov in sorted(os.listdir(ROOT)):
    pdir = os.path.join(ROOT, prov)
    if not os.path.isdir(pdir): continue
    sites = [d for d in os.listdir(pdir) if os.path.isdir(os.path.join(pdir, d))]
    def keyf(d):
        m = re.match(r'(\d+)', d)
        return int(m.group(1)) if m else 999
    print(f'### {prov} ({len(sites)} 사이트)')
    for s in sorted(sites, key=keyf):
        sdir = os.path.join(pdir, s)
        xlss = [f for f in os.listdir(sdir) if f.endswith('.xlsx') and 'backup' not in f.lower() and not f.startswith('_')]
        print(f'   {s}  ::  {xlss[0] if xlss else "(엑셀없음)"}')
