# -*- coding: utf-8 -*-
"""Gom album ảnh Trí QC (mtime 08/10 21:53) vào QC\images\_tri_0810\ + khử trùng md5."""
import glob, hashlib, os, shutil, time

SRC = os.path.join(os.environ['LOCALAPPDATA'], 'hermes', 'cache', 'images')
DST = r'C:\Claw 2\QC\images\_tri_0810'
os.makedirs(DST, exist_ok=True)
files = sorted(glob.glob(os.path.join(SRC, 'img_*.jpg')), key=os.path.getmtime, reverse=True)
moi = [f for f in files if time.strftime('%d/%m %H:%M', time.localtime(os.path.getmtime(f))) == '08/10 21:53']
print('ảnh trong lô album 08/10 21:53:', len(moi))
seen, n = {}, 0
for f in sorted(moi, key=os.path.getmtime):
    h = hashlib.md5(open(f, 'rb').read()).hexdigest()
    if h in seen:
        print('   bỏ (trùng md5):', os.path.basename(f)); continue
    seen[h] = os.path.basename(f)
    n += 1
    d = os.path.join(DST, 'tri_0810_%02d.jpg' % n)
    shutil.copy2(f, d)
    print('   %s → %s (%d byte)' % (os.path.basename(f), os.path.basename(d), os.path.getsize(d)))
print('đã gom', n, 'ảnh duy nhất →', DST)
print(sorted(os.listdir(DST)))
