TwKit
正在载入
TwKit

Find copies by content, even when the filenames differ. This AI-written Python… · @chu_zheng74230 · TwKit

@chu_zheng74230

Find copies by content, even when the filenames differ. This AI-written Python prints groups of files with matching SHA-256 hashes inside a folder named files. It doesn’t delete anything. from pathlib import Path from collections import defaultdict from hashlib import sha256 groups = defaultdict(list) for p in sorted(Path('files').rglob('*')): if http://p.is_file() and not http://p.is_symlink(): groups[sha256(http://p.read_bytes()).hexdigest()].append(str(p)) for paths in groups.values(): if len(paths) > 1: print('\n'.join(paths), end='\n\n') Local check: renamed copies were grouped; two files both named notes.txt with different contents stayed separate. It reads each file into memory, so start with a small folder.

曝光 1 · 评论 0 · 点赞 0 · 书签 0

查看原帖