2013-09-30 39 views
0

通常我趕緊更新我的待辦事項列表中創建一個名爲這樣一個新的空文件:如何從文件夾中的文件名創建新的iCal事件?

我只需要的是採取該文件夾中的所有文件工作流或AppleScript的

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

等..,提取物日期和文件名中的標題,並在該日使用該標題創建新的iCal事件!

這似乎很容易,但我怎麼能做到這一點?

+0

我想要使用的Automator,但無法找到使用從文件名作爲日的事件中提取的日期的任何有用的解決方案..沒有使用文件名的其餘部分作爲標題。我正在考慮使用蘋果,但我很新手上。 – Khalizar

回答

1

下面是直接Applescript中的東西。

注:這取決於你改變你的日期格式DD-MM-YYYY(由於的AppleScript在建日期解析器)

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 
+0

嘿@Khalizar做了這​​些答案的任何工作適合你?將很好的結束這個問題或者分享你自己的最終答案。 – adamh

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 
相關問題