2013-09-30 3 views
0

보통 내가 빨리이 같은 이름의 새 빈 파일 만들기 내 TODO 목록을 업데이트 : 등등폴더의 파일 이름에서 새 iCal 이벤트를 만들려면 어떻게해야합니까?

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

와 .. 난 그냥 폴더의 모든 파일을 워크 플로우 또는 AppleScript로 필요

을 추출 파일 이름의 날짜와 제목을 입력하고 해당 날짜에 해당 제목의 새 iCal 이벤트를 만듭니다.

너무 쉽게 보이지만 어떻게 할 수 있습니까?

+0

내가 자동화를 사용하려고 해요하지만 이벤트의 날이 파일 이름에서 추출 된 날짜를 사용하기위한 유용한 솔루션을 찾을 수 없습니다 .. 둘 다 제목으로 파일 이름의 나머지 부분을 사용하지 않습니다. 나는 applescript를 사용하는 것에 대해 생각하고 있었지만, 나는 그것에 아주 새내기 다. .. – Khalizar

답변

1

여기는 직선 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

(때문에 내장 날짜 파서 AppleScripts를에) DD-MM-YYYY로 날짜 형식을 변경하는 방법에 따라 달라집니다

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