【问题标题】:Applescript folder action for "Messages" text, tweak needed“消息”文本的 Applescript 文件夹操作,需要调整
【发布时间】:2013-12-06 08:24:03
【问题描述】:

我有一个文件夹操作,当一个新文件添加到文件夹并且它可以工作(有点)时,它会通过消息向我发送一条短信。这里是:

on adding folder items to this_folder after receiving added_items
    set added_Items_List to {}
    set dateString to (current date) as string
    set theBody to "New items have been added to " & name of (info for this_folder) & ": "

    tell application "Messages"
        set theBuddy to buddy "E:scottl44@this.net" of service "E:scott@that.com"
        send theBody & dateString to theBuddy
    end tell

end adding folder items to

问题是,如果添加 200 个文件,它会发送 200 个文本。

我希望它在添加第一个文件时向我发送一条消息,然后在给定的时间间隔内再忽略任何内容,例如 30 分钟。这可能吗?

另外,我希望它获取文件夹路径,至少从它所在的位置向上一个文件夹。

非常感谢!

【问题讨论】:

    标签: applescript messages imessage


    【解决方案1】:

    尝试使用临时文件。可以通过POSIX path of this_folder获取文件夹的完整路径:

    on adding folder items to this_folder after receiving added_items
        do shell script "f=${TMPDIR}messagesfolderaction;[[ ! -e $f || $(stat -f%m $f) -le $(date +%s)-1800 ]]&&touch $f||echo a"
        if result is not "" then return
        set body to "New items have been added to " & POSIX path of this_folder & (current date) as text
        tell application "Messages"
            send body to buddy "E:scottl44@this.net" of service "E:scott@that.com"
        end tell
    end adding folder items to
    

    【讨论】:

    • 嗯.. 除了更正地址中的域名外,我还需要做什么吗?当我启用它时,似乎什么都没有发生。谢谢!
    • 真的很好!我添加了一个文件并收到了消息,然后添加了几个文件并没有消息。伟大的!现在我正在等待 30 分钟后添加更多内容。只有一个问题:如果我想发送给多个人,那么我只需要复制“将正文发送给好友..”行并适当更改地址吗?
    • 现在 30 分钟后,我添加了文件,但没有收到消息。有任何想法吗?太好了,非常感谢您的帮助。
    • @scottl31 我真的应该更好地测试这些脚本。还有一个错误,但现在再试一次。
    • 在测试时,我将间隔更改为 3 分钟。所以会更容易。如果我在 3 分钟之前添加了另一个或更多文件。起来了,它会在 3 分钟结束时发送另一条消息。太棒了,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 2011-05-28
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多