0

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

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 分钟。这可能吗?

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

非常感谢!

4

1 回答 1

0

尝试使用临时文件。您可以使用以下命令获取文件夹的完整路径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
于 2013-11-22T14:16:55.753 回答