2014-10-31 28 views
0

我正在使用Outlook 2011 for Mac。AppleScript - 如何根據日曆事件的主題更改日曆事件的類別

的想法是標記爲「X123」所有日曆事件爲主題有一個新的類別:類別「布拉布拉」。有了這個改變,我還想刪除舊的類別,如果有的話。

我從Ramon's topic得到了一小段(謝謝!),但有人可以幫我解決問題,因爲問題有點不同。

這是我到現在爲止:

tell application "Microsoft Outlook" 
    set theCategory to first category whose name is "Blabla" 
    set theEventList to every calendar event whose (subject is "X123") 
    display dialog "There are " & (count of theEventList) & " Events." 
    set theEvent to item 1 of items of theEventList 

    set currentIdentityFolder to quoted form of POSIX path of (current identity folder as string) 
    set cmd to "mdfind -onlyin " & currentIdentityFolder & " 'kMDItemContentType == com.microsoft.outlook14.event && com_microsoft_outlook_categories == " & id of theCategory & "' | xargs -I % mdls -name com_microsoft_outlook_recordID '%' | cut -d'=' -f2 | sort -u | paste -s -" 
    set theEventIDs to words of (do shell script cmd) 

    set theCategory to {} 
    repeat with thisEventID in theEventIDs 
     -- set the new category 
     set theCategory to category "Blabla" 
     display dialog "test" 
    end repeat 
end tell 
+0

第一款存儲在'theEventList'類別「布拉布拉」裏面'theCategory',主題爲「X123」的所有活動,並與主題的第一事件「 X123「在'theEvent'中。第二段存儲所有類別爲「Blabla」的事件。第三段遍歷'theEventIDs'並覆蓋類別爲「Blabla」的'Category'並每次顯示** test ** **! 你想用第一段的'theEventList'做什麼?在第三段內部,你可能希望'將日曆事件id的類別設置爲theCategory',這是否符合你的問題? – ShooTerKo 2014-10-31 22:08:10

回答

0

感謝ShooTerKo。我有一位天才的幫助。這件作品的AppleScript的是我自己的問題的答案:

tell application "Microsoft Outlook" 
    set theCategory to category "Blabla" -- theCategory = "Blabla" 
    set theEventList to every calendar event whose subject contains "X123" -- theEventList contains "X123" 

    -- Loop through each event 
    repeat with theEvent in theEventList 
     set category of theEvent to {} -- Empty all other categories 
     set category of theEvent to {theCategory} -- Set the new category to theCategory 
    end repeat 
end tell