TGStat
TGStat
Type to search
Advanced channel search
  • flag English
    Site language
    flag Russian flag English flag Uzbek
  • Sign In
  • Catalog
    Channels and groups catalog Regional compilations Thematic compilations Платные каналы Search for channels
    Add a channel/group
  • Ratings
    Rating of channels Rating of groups Posts rating
    Ratings of brands and people
  • Analytics
  • Search by posts
  • Telegram monitoring
  • Promotion
    Advertising through Yandex Business Advertising in channels through TGStat Agency Advertising on TGStat.ru website
PytStart | Программирование на Python

29 Aug, 15:11

Open in Telegram Share Report

🖥 Как найти дубликаты в папке с помощью Python

Например, в папке лежат сотни файлов, и нужно понять, какие из них полностью одинаковые.

Можно сравнивать их по хэшу 👇


from pathlib import Path
import hashlib

def get_hash(path):
return hashlib.md5(path.read_bytes()).hexdigest()

files = {}

for file in Path("files").iterdir():
if file.is_file():
file_hash = get_hash(file)
files.setdefault(file_hash, []).append(file)

for group in files.values():
if len(group) > 1:
print("Дубликаты:")
for file in group:
print(" ", file)

💡 Идея простая:

📄 файл → 🔢 хэш → 🔍 сравниваем хэши

Если хэши совпали, файлы с высокой вероятностью одинаковые.

🔥 Такой скрипт можно использовать для:
— очистки папок
— поиска повторяющихся фото
— анализа больших архивов
— автоматизации работы с файлами

546 0 10 3
Catalog
Channels and groups catalog Channels compilations Search for channels Add a channel/group
Ratings
Rating of Telegram channels Rating of Telegram groups Posts rating Ratings of brands and people
API
API statistics Search API of posts API Callback
Our channels
@TGStat @TGStat_Chat @telepulse @TGStatAPI
Read
Академия TGStat Telegram Research 2019 Telegram Research 2021 Telegram Research 2023
Contacts
Справочный центр Support Email Jobs
Miscellaneous
Terms and conditions Privacy policy Public offer
Our bots
@TGStat_Bot @SearcheeBot @TGAlertsBot @tg_analytics_bot @TGStatChatBot