我有一个文件夹操作,当一个新文件添加到文件夹中并工作时,它会通过Messages向我发送一条文本消息(有点)。这是:
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分钟。这可能吗?
此外,我希望它能获得文件夹路径,从它所在的位置至少有一个文件夹。
非常感谢!
尝试使用临时文件。您可以使用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