Sanko
V2EX  ›  问与答

有什么好用的照片去重复软件或者脚本

  •  
  •   Sanko · Jan 23, 2018 · 2048 views
    This topic created in 3040 days ago, the information mentioned may be changed or developed.
    ```python
    import os
    import hashlib
    import time
    def main():
    start = time.time()
    file_del,file_num,md5_all,size_all = 0,0,[],[]
    path = input('path:')
    if os.path.isdir(path):
    for root,dirs,files in os.walk(path):
    for name in files:
    file = os.path.join(root,name)
    file_num += 1
    size = os.path.getsize(file)
    if size in size_all:
    with open(file,'rb') as f:
    md5 = hashlib.md5(f.read()).hexdigest()
    if md5 in md5_all:
    os.remove(file)
    file_del += 1
    else:
    md5_all.append(md5)
    else:
    size_all.append(size)
    else:
    print('路径错误!')
    end = time.time()
    print('共扫描'+str(file_num)+'个文件')
    print('共删除'+str(file_del)+'个文件')
    print('共耗时'+str(end-start)+'秒')
    if __name__ == '__main__':
    main()
    ```
    感觉我这样写会误删好多
    6 replies    2018-01-23 20:59:49 +08:00
    Sanko
        1
    Sanko  
    OP
       Jan 23, 2018 via Android
    rzti483NAJ66l669
        2
    rzti483NAJ66l669  
       Jan 23, 2018 via iPhone
    删除部分还是手工操作好
    rzti483NAJ66l669
        3
    rzti483NAJ66l669  
       Jan 23, 2018 via iPhone
    忘说了程序我用的是 visipics
    ELLIA
        4
    ELLIA  
       Jan 23, 2018
    JohnChu
        5
    JohnChu  
       Jan 23, 2018 via iPhone
    楼主是用 md5 检测的?
    qgswzmz
        6
    qgswzmz  
       Jan 23, 2018 via Android
    有个 vsduplicateimagefinder pro 网上找找有破解 曾经用过的 感觉结果还行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   949 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 21:40 · PVG 05:40 · LAX 14:40 · JFK 17:40
    ♥ Do have faith in what you're doing.