1

我是 applescript 的新手,但我想设置一个文件夹操作:

1. Recognises when a file is added to a folder
2. Tags said folder red
3. Adds a Reminder to the "Downloads" reminder list that has the name of the newly-added file as the body text of the reminder

到目前为止,使用谷歌和 Applescript 的记录功能,我已经把它一起写了

property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.

on adding folder items to this_folder after receiving added_items



try
    tell application "Finder"
        set FILEname to name of (added_items)
        set label index of folder "untitled folder" of folder "Desktop" of folder "heyjeremyoates" of folder "Users" of startup disk to 2
    end tell

    tell application "Reminders"
        set mylist to list "Downloads"
        tell mylist
            make new reminder with properties {name:"D/L Complete", body:FILEname, due date:(current date)}
        end tell
    end tell
end try

end adding folder items to

该死的东西行不通。真气。我将其作为文件夹操作进行了测试,其中“test”作为提醒的名称和正文,并且效果很好。我很确定我在将 FILEname 设置为新复制项目的名称时出错了,因为现在的脚本不再将文件夹变为红色。

这背后的想法是,我可以从我的 iPhone/iPad 看到有多少大型/计划下载到我的家庭 mac(种子和大型工作文件 - 我将为每个下载文件夹提供单独的文件夹操作和提醒列表)还有一些尚待管理。

如果 iCloud/Reminders 和十几行代码无论如何都能提供我想要的东西,那么设置 Growl/Prowl 组合似乎是一种浪费。理想情况下,我会编写第二个applescript,当我重命名或移动相关文件时删除提醒,虽然我什至没有想过如果有人对此有任何建议会如何工作,我将非常感激

遗憾的是,您不能(本机)将 OSX 通知推送到链接到同一个 iCloud 帐户的 iOS 设备(具有适当的粒度)

但我离题了 - 谁能看到我在这里搞砸了什么?

在此先感谢您阅读本文

4

1 回答 1

1

added_items是别名列表,并name of (added_items)导致错误。

on adding folder items to this_folder after receiving added_items
    tell application "Finder"
        set label index of this_folder to 2
        repeat with f in added_items
            set n to name of f
            tell application "Reminders" to tell list "Downloads"
                make new reminder with properties {name:"D/L Complete", body:n, due date:(current date)}
            end tell
        end repeat
    end tell
end adding folder items to

(保存脚本~/Library/Workflows/Applications/Folder Actions/并从文件夹操作设置中启用文件夹操作。)

于 2013-10-07T12:35:03.693 回答