Macos 修改/添加/删除文件时显示通知

Macos 修改/添加/删除文件时显示通知,macos,notifications,applescript,Macos,Notifications,Applescript,我想创建一个applescript,当特定文件夹中的文件被添加/修改/删除时,它会显示os X通知 我无意中看到了我想要显示的内容,但不知道如何通过监视文件夹被修改来实现它 不太了解applescript,但有一些web开发经验 感谢您的帮助 谢谢 p如果不进行编码,您最好编写一个启动配置: <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd

我想创建一个applescript,当特定文件夹中的文件被添加/修改/删除时,它会显示os X通知

我无意中看到了我想要显示的内容,但不知道如何通过监视文件夹被修改来实现它

不太了解applescript,但有一些web开发经验

感谢您的帮助

谢谢


p

如果不进行编码,您最好编写一个启动配置:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>org.test.watch</string>
        <key>ProgramArguments</key>
        <array>
                 <string>/script/to/run</string>
                 <string>arg</string>
                 <string>otherArg</string>
        </array>
        <key>WatchPaths</key>
        <array>
                 <string>/dir/to/watch/</string>
        </array>
</dict>
</plist>

标签
org.test.watch
程序参数
/脚本/到/运行
arg
其他人
监视路径
/dir/to/watch/
将其放入
~/Library/LaunchAgents/org.test.watch.plist
并使用
launchctl load~/Library/LaunchAgents/org.test.watch.plist
加载。 每当/dir/to/watch下的文件或文件夹发生问题时,都会调用/script/to/run

您可以在
man launchd.plist
中找到更多信息

请注意,它不允许您知道实际发生了什么,只是某些事情发生了变化。如果您需要更多详细信息,则需要使用FSEvents框架进行一些编码