AI 一秒生成的 pc 查重清理小工具 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
sosme
V2EX    编程

AI 一秒生成的 pc 查重清理小工

  •  
  •   sosme 2024-10-25 17:35:17 +08:00 1237 次点击
    这是一个创建于 425 天前的主题,其中的信息可能已经有所发展或是发生改变。

    功能:查找硬盘重复文件并询问是否清理 思考:人与机器沟通的门槛越来越低,人只需要把想法/需求提给 ai 立刻可以获得想要的结果,完全不需要自己思考写代码,“程序员”或许会消失,取而代之的是“AI 对接员”

    ai 代码:

    import os import hashlib

    def hash_file(file_path): """计算文件的哈希值""" hasher = hashlib.md5() # 可以使用其他哈希函数 with open(file_path, 'rb') as f: while chunk := f.read(8192): hasher.update(chunk) return hasher.hexdigest()

    def find_duplicates(root_folder): """查找重复文件""" hashes = {} duplicates = []

    for dirpath, _, filenames in os.walk(root_folder): for filename in filenames: file_path = os.path.join(dirpath, filename) file_hash = hash_file(file_path) if file_hash in hashes: duplicates.append((file_path, hashes[file_hash])) else: hashes[file_hash] = file_path return duplicates 

    def main(): # 指定搜索的根目录,例如 C:\ 或者其他驱动器 root_folder = input("请输入要搜索的根目录(例如 C:\):")

    duplicates = find_duplicates(root_folder) if not duplicates: print("未找到重复文件。") return print("找到的重复文件:") for i, (file1, file2) in enumerate(duplicates): print(f"{i + 1}: {file1}\n {file2}") # 删除选择 while True: choice = input("请输入要删除的文件编号(或者输入 'q' 退出):") if choice.lower() == 'q': break try: index = int(choice) - 1 if 0 <= index < len(duplicates): file_to_delete = duplicates[index][0] os.remove(file_to_delete) print(f"已删除文件: {file_to_delete}") duplicates.pop(index) # 从列表中移除已删除的项 else: print("无效的编号。") except ValueError: print("请输入有效的编号。") 

    if name == "main": main()

    目前尚无回复
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2999 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 12:12 PVG 20:12 LAX 04:12 JFK 07:12
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86