通常我会快速更新我的TODO列表,创建一个名为这样的新空文件:
2013-10-01 Tell a friend that stackoverflow rocks
2013-10-23 Prepare my super meeting about coding
依旧......
我只需要一个工作流程或AppleScript,它可以获取文件夹中的所有文件,从文件名中提取日期和标题,并在当天用该标题创建一个新的iCal事件!
看起来很容易,但我怎么能实现呢?
答案 0 :(得分: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
答案 1 :(得分: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