“消息”文本的Applescript文件夹操作,需要调整

时间:2013-11-21 17:44:21

标签: applescript messages imessage

我有一个文件夹操作,当一个新文件被添加到该文件夹​​时,它会通过消息向我发送文本消息,并且它可以正常工作(排序)。这是:

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

另外,我希望它能够获取文件夹路径,至少有一个文件夹。

非常感谢!

1 个答案:

答案 0 :(得分: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