0

通常我会快速更新我的 TODO 列表,创建一个新的空文件,如下所示:

2013-10-01 Tell a friend that stackoverflow rocks
2013-10-23 Prepare my super meeting about coding

等等..

我只需要一个工作流或applescript,它可以获取文件夹中的所有文件,从文件名中提取日期和标题,并在那天使用该标题创建一个新的 iCal 事件!

这似乎很容易,但我怎样才能做到这一点?

4

2 回答 2

1

这是直接 Applescript 中的内容。

注意:这取决于您将日期格式更改为 DD-MM-YYYY(由于内置日期解析器中的 Applescripts)

tell application "Finder"
    set data_folder to folder POSIX file "/Users/me/Desktop/my_ical_data"
    set all_items to every item of data_folder
end tell

set my text item delimiters to {" "}

repeat with cur_item in all_items
    set nm to the name of cur_item
    set event_date to date (text item 1 of nm)
    set event_desc to (text items 2 thru -1 of nm) as string
    tell application "iCal"
        tell calendar "Work" -- name of calendar you wish to add to
            make new event with properties {summary:event_desc, start date:event_date, description:""}
        end tell
    end tell
end repeat
于 2013-10-01T22:16:28.183 回答
0

这不需要您在系统偏好设置中更改日期格式:

tell application "Finder" to name of items of folder POSIX file "/Users/username/todo"
repeat with l in result
    set s to text ((offset of space in l) + 1) thru -1 of l
    set d to current date
    tell d to set {year, month, date, time} to {text 1 thru 4 of s, text 6 thru 7 of s, text 9 thru 10 of s, 0}
    tell application "iCal" to tell calendar "Work"
        make new event with properties {summary:s, start date:d}
    end tell
end repeat
于 2013-10-02T05:11:01.360 回答