【问题标题】:Parse iCal events using Mac OS X Automator使用 Mac OS X Automator 解析 iCal 事件
【发布时间】:2016-01-24 11:15:48
【问题描述】:

Here's the file I've created

The same file uploaded to different filestorage

我要做的是从 iCal 事件摘要中获取公司名称和日期,并将它们放入 Excel 文件或局部变量中。摘要具有以下模式:

$_Compamy name 11.11.2011

例子:

$_ОАО "Газпром" 11.11.2011
$_Gazprom OJSC 11.11.2011

我的想法是过滤包含 $_ 的条目,然后修剪最后 10 个字符(或从摘要中提取日期)。 问题在于自动机的事件摘要功能,它会生成太多像这样的奇怪文本:

TOTAL EVENTS: 3

EVENT 1 OF 3
Summary:    $_Gazprom OJSC 11.11.2011
Status: none
Date:   10/6/15 to 10/6/15
Time:   9:00:00 AM to 10:00:00 AM

我需要分别构建姓名列表和日期列表,以便将它们用于文档填写,但我不知道如何获取日历中所有事件的特定文本。

【问题讨论】:

    标签: macos applescript automator osx-elcapitan


    【解决方案1】:

    如果您只想要一个摘要字符串列表,而不需要所有奇怪的文本,您将需要使用 AppleScript,或者作为独立脚本,或者在 Automator 内的 Run AppleScript 操作中使用.以下是一些通用代码,它们将创建一个仅包含特定日历中一周日期摘要的列表,并在 cmets 中进行一些解释:

    --This section just defines a pair of dates to search within the Calendar
    set rightNow to current date --Today
    set rightNow's time to 0 --Set the time to the beginning of the day
    set oneWeek to rightNow + (days * 7) --Add 7 days to get a week of Events
    
    set eventSummaries to {} --Define an empty list to hold all of the Event Summaries
    tell application "Calendar"
        set thisCalendar to item 1 of (get every calendar whose name is "Craig") -- Identify the Calendar to pull the Events from
        set theseEvents to every event of thisCalendar whose start date is greater than rightNow and start date is less than oneWeek -- Get the Events
        repeat with eachEvent in theseEvents
            set end of eventSummaries to eachEvent's summary -- Add each Event's Summary to the empty list
        end repeat
    end tell
    

    祝你好运,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-07
      • 1970-01-01
      • 2010-12-12
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2015-09-24
      • 2012-07-11
      相关资源
      最近更新 更多