Scripting iCal Events

As part of a school project, my students gather weather data when a specific NASA satellite passes over our school. We have to keep an eye on the schedule we receive and collect our data. Every once in a while we forget and miss an overpass. I decided to enter the satellite overpasses as iCal events and have an alarm sound to remind us. This tedious task of entering the events sounds like a great job for AppleScript. This AppleScript project is a little over my head because I don't understand insides of iCal and AppleScripting.
The satellite schedule comes as text in an email and looks like this:
Date & Time | Satellite Position
Mo Day Year Local UT | view sat azm relative solar sat. position sat
Time | zenith fr. N azimuth zenith lat. long dir
Local Time = UT + (-6.0)
9 16 2008 12:19 18 19 | 6.46 104.44 51.37 40.32 39.94 249.13 des
9 17 2008 13:02 19 02 | 54.05 289.85 117.31 38.45 42.22 239.04 des
9 18 2008 12:07 18 07 | 27.40 102.13 49.98 42.00 39.43 252.03 des
9 19 2008 12:50 18 50 | 42.63 287.75 119.55 39.58 41.48 241.85 des
9 20 2008 11:55 17 55 | 43.58 99.08 49.57 43.80 39.09 254.98 des
The only important info for our observations is the Mo, Day, Year and UT time — the other satellite info is not relevant to our observations.
How would I write a AppleScript that would strip away the unimportant info and create a different event each time for the satellite overpass? The iCal event would need to start 15 minutes before and end 15 minutes after the UT time given.
TIA
Message was edited by: Stephen Bunker

Here is some sample code.
-- Code starts here --
property tFile : "HD01:Users:dev_sleidy:Desktop:SatelitePasses.txt" -- Location of Satellite information file.
property tCalendar : "Satellite" -- Name of 'iCal' 'Calendar'.
set tText to paragraphs 5 through -1 of (read file tFile) -- Obtain specific lines (paragraphs) of Satellite information file data.
set {oASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, " "} -- Configure delimiter.
tell application "iCal" -- Focus on 'iCal' commands.
tell calendar tCalendar -- Focus within the 'tCalendar' calendar.
repeat with i in tText -- Cycle through the obtain paragraphs of data.
tell i to set {tMonth, tDay, tYear, tTime, uHour, uMinute} to {first text item as number, second text item as number, third text item as number, fourth text item, fifth text item, sixth text item} -- Obtain specific information from within a paragraaph.
-- Create a new 'date' based on obtained Satellite data.
set tDate to (((tYear as string) & "-" & my handle_Number(tMonth)) & "-" & my handle_Number(tDay)) & "T" & tTime as «class isot» as date
-- Create a new 'iCal' event, including 'display alarm' setting.
set tEvent to make new event at end with properties {start date:tDate, end date:tDate, description:(uHour & "." & uMinute & " UTC")}
tell tEvent to make new display alarm at end with properties {trigger interval:-15}
end repeat
end tell
end tell
set AppleScript's text item delimiters to oASTID -- Reset delimiter.
on handle_Number(lNumber) -- Manage single digit date values.
if (lNumber < 10) then set lNumber to "0" & lNumber
return (lNumber as string)
end handle_Number
-- Code ends here --
You may have to edit the code, as per the delimiters you use / set within 'System Preferences' 'International's 'Formats' 'Dates' and 'Times' configuration panels.

Similar Messages

  • Script that speaks the iCal event that ran it

    Is it possible to write a one-script-fits-all AppleScript that is aware of the iCal Event that called it (using an alarm)?
    If so, is there an easy way to get the title of that event in order to use it with a 'say' command?

    Hi,
    Does this behaviour occur on a new user account on her machine?
    If not then remove the 'com.apple.iCal.plist' file in from the problem account. The com.apple.iCal.plist file under the User profile in ~/Library/Preferences. Quit iCal, drag the .plist file to the Desktop. Restart and check iCal for normal behaviour.
    Best wishes
    John M

  • Is there a way to automatically remove URL's from iCal events?

    Is there a script or any easy way to remove URL's from iCal events? I like to print my daily calendar to insert into a small day planner but I have very long URL's wasting up space.

    For dealing with duplicates in iPhoto check out Duplicate Annihilator
    Regards
    TD

  • Applescript ical event at specific time of day

    I'm trying to find a way to have a script create an iCal event for a day away. I use (current date + 1 * days) but this creates the event one day away at the time the script runs. is there a way to create the event one day away at 8:00am each time?

    The current date includes the time, so you can just set the time separately, for example
    set theDate to ((current date) + 1 * days)
    set time of theDate to 8 * hours
    theDate -- > next day at 8:00AM

  • Convert email to ical events

    I am looking for a way to automatically convert emails i recieve into calendar events in different calendars. I have looked into the mail.app "add invitations automatically" but i dont want all my email accounts to sync with the calendars.
    I have tried mail2ical (every event gets put into one calendar, and the event time is the time of the email recieved), eventmaker (it thinks i am making events for the future). I have taken a look into automator, but im not sure if it has the actions im looking for.  
    I manage 5 different people and their work schedules. At the end of a day, after multiple projects have been worked on, i get 5 different emails each from 5 different people. Each email outlines different projects  they worked on ( project name is in the subject line), along with the time they worked and what they did.
    My current workflow is i go through each email one by one. I copy the contents of the email, then click on the time they worked to open a ical event. I then paste the contents into the notes and create a event. Each person has their own calendar which show the projects they have worked on for the day.
    I will be gettting another 5 more people to manage and with this workflow i will be manually sorting 50 emails a day! In the long run this isnt a effienct workflow, im looking for a way to automate this entirely.

    Hi,
    I wouldn't expect you are going to find an application to do that, as the format the emails you mention could vary widely.  Posibly some sort of bespoke script could do it.
    Best wishes
    John M

  • Link email to iCal event as a Service?

    This topic was discussed here http://discussions.apple.com/thread.jspa?messageID=1029973&#1029973
    but is archived and not accepting replies, hence the re-post.
    There's an Applescript to link an email to an iCal event using the file:// protocol, but I was wondering if someone who knows about this stuff could achieve a similar effect as a Mac OS X Service, to which a keyboard shortcut could be attached. That way, people can link an email in Mail.app to a new iCal event quickly.

    Hi Jeff,
    No problem.
    You will need to change the line that starts set myCalendar to to the name of the calendar you want the todos added to.
    -- Todo from Mail.app email --
    -- Taken from Find Email File Path --
    -- John Maisey --
    -- Will only work in OS 10.4 or later --
    -- 0.5
    -- 13 Dec 2005
    -- What it does:
    -- Makes iCal todo with the path of the first selected email message. This method will only work if you do not move the message to another folder in Mail.app.
    -- Fixed to deal with quotes in email subject (24/8/5)
    -- Fixed to deal with unusually set TID's (24/8/5)
    -- Fixed to deal with various time formats (26/8/5)
    -- Changed search from date to ID (26/8/5)
    -- Added Python script to url encode file path (26/8/5)
    -- Added iCal todo creation (13/12/05)
    set myCalendar to "Your Calendar" -- Change this to the title of your calendar.
    tell application "Mail" to set mailList to selection
    try
    tell application "Mail" to set {myTitle, myID} to {subject, id} of item 1 of mailList
    on error
    display dialog "Check that you have an email selected in Mail.app" buttons {"OK"}
    return
    end try
    set {myDels, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"\""}}
    set myTitle to text items of myTitle
    set AppleScript's text item delimiters to {"\\\""}
    set myTitle to myTitle as text
    set AppleScript's text item delimiters to myDels
    set someEmails to paragraphs of (do shell script "mdfind \"kMDItemTitle == '" & myTitle & "' && kMDItemKind == 'emlx'\"")
    repeat with anEmail in someEmails
    if anEmail contains myID then exit repeat
    end repeat
    set myFile to do shell script "python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of anEmail
    try
    tell application "iCal" to make new todo at the end of todos of calendar myCalendar with properties {summary:myTitle, url:("file://" & POSIX path of myFile)}
    on error theErr
    display alert "An error occured" message theErr
    end try
    enjoy.
    John M

  • What is the minimal Format of an iCal event to attach to an email?

    Hello all!
    I just finished a large order page for a taxi friend. I would like to send the order with an iCal event attached to an email. He should only click on this new file, to enter this pickup order to his iCal ...
    I am struggling with the format. In my CGI script I have the following format, where the $variables are replaced with the convinient strings:
    BEGIN:VCALENDAR
    BEGIN:VEVENT
    DTEND;TZID=Europe/Berlin:$ical_data_end
    SUMMARY:$ical_summary
    DTSTART;TZID=Europe/Berlin:$ical_data_start
    DTSTAMP:$ical_dtstamp
    LOCATION:$ical_location
    SEQUENCE:0
    DESCRIPTION:$ical_comment
    BEGIN:VALARM
    TRIGGER:-PT1H
    DESCRIPTION:Event reminder
    ACTION:DISPLAY
    END:VALARM
    END:VEVENT
    END:VCALENDAR
    Does a time string like "20120608T123500" has to finish with a "Z" ? Do I need additional informations, like "UID:", "X-WR-ALARMUID:" ... In any case my iCal event sent by email is not adding to the iCal saying: "iCal can't read this calendar. No events have been added to your iCal calendar."
    I would be grateful for any hint
    marek

    Surprise Surprise!
    I realized after heavy testing, that a DTSTAMP: is not needed.
    But there is apparently a problem with the DATE-TIME format: Perhaps for other readers, which are in such a desparate situation, as I am since two days now!!! here some explanations:
    The reference about iCal format you find in RFC 5546
    DTSTART; and DTEND; have a time string like follows:
    yyyymmddThhmmss
    In the middle the big letter "T". But you have to add the time zone: for me it is the following:
    DTSTART;TZID=Europe/Berlin:20120608T062500
    Now the big surprise: this time format with an hour over 12 ooops! I tested now once again like follows
    DTEND;TZID=Europe/Berlin:20120608T212500
    DTSTART;TZID=Europe/Berlin:20120608T202500
    changing the hh (hours) with one hour difference up until here. 10 Minutes again, iCal was freezing with hours over 19. I swear!
    Ok to answer my original question: What is the minimal format of an iCal event, which you may attach to an email:
    BEGIN:VCALENDAR
    BEGIN:VEVENT
    DTEND;TZID=Europe/Berlin:20120608T212500
    SUMMARY:Name
    DTSTART;TZID=Europe/Berlin:20120608T202500
    LOCATION:MUC
    SEQUENCE:0
    BEGIN:VALARM
    TRIGGER:-PT1H
    DESCRIPTION:Event reminder
    ACTION:DISPLAY
    END:VALARM
    END:VEVENT
    END:VCALENDAR
    But be aware, that this is buggy. Be carefull and have a nice evening
    marek

  • Help creating an iCal event workflow

    I'm trying to create a workflow where I run & a window pops up so I can add the details & then it adds the details to iCal.
    I was trying to use the 'New iCal Events' action which when run display a window where you can enter the details, but it won't work properly for me. If I run it from Automator the details I enter are added correctly to iCal, but if I run it from the workflow I saved (as an app) the details I enter don't get transferred to iCal.
    Is this a bug, or am I doing something wrong?

    don't hope too much. automator bugs haven't received high priority in the past. you might want to look for a workaround using apple script.

  • Contact attachment to iCal event

    How to attach contact card to iCal event for following aim: "Call to Jone (contact attached)"?.

    a bit surprised that you can't do this more easily, I wrote a script to put the selected or chosen AB contact into the URL field of the selected iCal event.
    see:
    http://www.woodenbrain.com/stuff/scripts.html

  • Tagging an ical event with contact?

    Is it possible to tag an iCal event with a contact from the Address Book?  Or attach notes to the event?  Or link to files??

    Hi,
    It is possible to link an event to an Address Book contact using the URL field. I have an Applescript application to create these URLs when you have an Address Book contact selected. See the script Link to Address Book on this page.
    Best wishes
    John M
    As I sell software on my site and ask for donations, the Apple Support Communities Use Agreement requires that I state that I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • AppleScript opens iCal event, but prompt to add event doesn't pop up

    Ok, so I have a script that I cobbled together from other sources to do the following:
    It will read an emailed iCal event and look for the "ORGANIZER" line and delete it, after which it opens iCal and adds the event to whichever calender i choose. I made it a droplet app and also an application bundle so that i could set it as my default app for .ics files. I need this because of some strange happenings when dealing with CalDEV, if the ORGANIZER line is present, people can't add the events in iCal.
    Here's the problem, the script functions exactly the way i want up until opening iCal. iCal opens, but the prompt asking which calendar you'd like to add the event to never appears, or rather the prompt only appears after i've clicked away from iCal. So if iCal opens, and I stay on it, every click following is just answered by a beep (which is the, "there's an alert window open, and you need to respond to it" beep, but it isn't until i click away from iCal that the prompt appears.
    here's the script:
    property pTypeList : {".ics"}
    on open processItem
    set SomeFile to (processItem)
    set SomeText to (read SomeFile)
    set {SearchText, ReplaceText} to {"ORGANIZER", ""}
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, SearchText}
    set {TextItems, AppleScript's text item delimiters} to {text items of SomeText, ReplaceText}
    set {SomeText, AppleScript's text item delimiters} to {TextItems as text, TempTID}
    set OpenFile to open for access SomeFile with write permission
    try
    set eof of OpenFile to 0
    write (SomeText) to OpenFile as text
    close access OpenFile
    end try
    tell application "iCal" to open SomeFile
    end open
    If i change the last tell line to have "Finder" open SomeFile, the droplet works fine, but I can't set the script as a default app since it will get stuck in an endless loop. I myself don't mind have to drag the events to the script, but i wrote this for people in my office, and the less they have to do the better.
    I'm not sure of the problem has anything to do with the script but any suggestions would be greatly appreciated and thanks ahead of time.

    Hi,
    I think you'll need to tell iCal to 'activate' or the dialog window gets stuck behind iCal's main window.
    Something like:
    tell application "iCal"
    activate
    open SomeFile
    end tell
    Best wishes
    John M

  • Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?

    Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
    This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
    If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
    Thankyou
    Andrew.

    Andrew,
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
    If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback.

  • Lion 10.7.2 On both mac book pro and iMac, both with Lion 10.7.2, obtain repeated iCal event notifications from calendar or address book.  Cannot turn these off.  They repeat several times per session and every time computer is used.  How to diagnose this

    Lion 10.7.2 On both mac book pro and iMac, both with Lion 10.7.2, obtain repeated iCal event notifications from calendar or address book.  Cannot turn these off.  They repeat several times per session and every time computer is used.  How to diagnose this?

    First, uninstall "SuperTV" (whatever that is) according to the developer's instructions. It isn't working and it's filling the log with noise.
    If you have more than one user account, these instructions must be carried out as an administrator.
    Launch the Console application.
    Step 1
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left.
    Enter "BOOT_TIME" (without the quotes) in the search box. Note the timestamps of those log messages, which refer to the times when the system was booted. Now clear the search box and scroll back in the log to the last boot time when you had the problem. Post the messages logged before the boot, while the system was unresponsive or was failing to shut down. Please include the BOOT_TIME message at the end of the log extract.
    Post the log text, please, not a screenshot. If there are runs of repeated messages, post only one example of each. Don’t post many repetitions of the same message. When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    PLEASE DO NOT INDISCRIMINATELY DUMP THOUSANDS OF LINES FROM THE LOG INTO A MESSAGE. If you do that, I will not respond.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.
    Step 2
    Still in Console, look under System Diagnostic Reports for crash or panic logs, and post the most recent one, if any. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • I updated my iPhone 4 to iOS5 and let it sync with my Macbook and now all my iPhone iCal entries are gone. How can I get my iCal events back on my iPhone?

    I updated my iPhone 4 to iOS5 and let it sync with my Macbook (running Lion) and now all my iPhone iCal entries are gone. How can I get my iCal events back on my iPhone?

    Me too!  Help anyone?

  • ICal events are missing Day and Month in date

    Hello, Sorry if this has been addressed elsewhere - this is such a weird fault I was not sure how to search for it.
    My iCal events are missing the Day and Month in their start and end dates - it just shows a 4 digit year which can only be edited as a 4 digit number. All my events are in their correct places but I am unable to create new multiday events.
    This applies to old and new events alike. I tried trashing my iCal prefs file but it made no difference.
    Anyone any ideas? I am using iCal 3.0.8 on Leopard 10.5.8.
    Thanks in advance.

    Worked it out - I was using a custom date format to give me day and date in the menu bar - reverting to one of the standard built in 'British' works - but then I lose my day in the menu bar....

Maybe you are looking for