[求助]网络映射地址是否有办法实现新文件提醒? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
XentaiZ
V2EX    程序员

[求助]网络映射地址是否有办法实现新文件提醒?

  •  
  •   XentaiZ 2023-02-23 18:36:39 +08:00 1195 次点击
    这是一个创建于 960 天前的主题,其中的信息可能已经有所发展或是发生改变。

    事情是这样的:

    本人目前在高校工作,学校有一个大型 NAS ,校园网内可以通过映射网络驱动器的选项添加在自己的计算机里,然后每个所都有自己的一个文件夹,文件夹里每位同事又有自己的一个文件夹(没错就是套娃)。

    我每次给楼下电镜的阿姨送样,阿姨测完之后,会把电镜照片,样品组分等等文件塞到我的网盘文件夹里,问题是,我根本不知道阿姨什么时候测好,什么时候上传文件。我只有自己去问,或者不断查看我的文件夹。。。很累。。。

    有没有办法写个脚本,对我的文件夹进行监控,发现有新文件了,马上通知我,这样我就知道样品测好了。。。

    求大佬帮忙呜呜呜>_<

    heybuddy
        1
    heybuddy  
       2023-02-23 21:25:27 +08:00
    python 写个定时脚本,cd 到指定目录,执行完后记录最后脚本的执行时间,再去对应的文件夹里查看有没有比最后检测时间大的,有的话用 webhook/钉钉机器人 /server 酱 /bark 通知一下
    XentaiZ
        2
    XentaiZ  
    OP
       2023-02-23 22:20:06 +08:00
    @heybuddy 感谢,有那么点感觉,我研究研究
    vivisidea
        3
    vivisidea  
       2023-02-23 22:46:22 +08:00
    这种需求可以试试问问 chatgpt ,我感觉是比较能出方案的,我瞎问了一个,你参考参考 :D
    ```
    # write python program to monitor a network directory, if directory changes detected, invoke dingtalk webhook api

    import os
    import requests

    # Set the directory you want to monitor
    directory = '/tmp/some_folder'
    # DingTalk webhook URL
    dingtalk_url = 'https://oapi.dingtalk.com/robot/send?access_token=YOUR_DINGTALK_ACCESS_TOKEN'

    # Get the files in the directory
    files = os.listdir(directory)
    # Get the modified times of the files
    modified_times = [os.path.getmtime(os.path.join(directory, file)) for file in files]
    # Make a copy of the modified times
    previous_times = modified_times.copy()
    # Monitor the directory
    while True:
    # Get the modified times
    modified_times = [os.path.getmtime(os.path.join(directory, file)) for file in files] # Compare the modified times
    for index, time in enumerate(modified_times):
    if time != previous_times[index]:
    # Invoke DingTalk webhook
    data = {
    "msgtype": "text",
    "text": {
    "content": f"Directory {directory} changed"
    }
    }
    requests.post(dingtalk_url, json=data)
    break
    # Make a copy of the current modified times
    previous_times = modified_times.copy()


    ```
    XentaiZ
        4
    XentaiZ  
    OP
       2023-02-24 04:56:14 +08:00
    @vivisidea 我艹,大佬大佬,膜拜。我个人比较常用 C charp ,python 我只学了三天不过我还是能大致读懂的,我按照你们思路摸索一下
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2953 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 13:38 PVG 21:38 LAX 06:38 JFK 09:38
    Do have faith in what you're doing.
    ubao 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