The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Import iCal Events to OmniFocus Action (http://forums.omnigroup.com/showthread.php?t=22120)

SpiralOcean 2011-09-11 10:05 PM

Import iCal Events to OmniFocus Action
 
1 Attachment(s)
Script that imports iCal Events into OmniFocus actions.
Useful for forecast mode and the satisfaction of checking off events as if they were actions.

Requirements:
iCal Buddy
[url]http://hasseg.org/icalBuddy/[/url]

Tested in Lion. Still may have some bugs in it. Shouldn't do anything like delete important data. It will delete any action with the text
iCal UID:
in the note field.

Much gratitude and thanks to the following authors, developers, websites:

iCalBuddy: without which this script would not have worked.
[url]http://hasseg.org/icalBuddy/[/url]

Other helpful resources:
[url]http://hints.macworld.com/article.php?story=20091115201138792[/url]
[url]http://macscripter.net/viewtopic.php?id=24737[/url]
[url]http://www.latenightsw.com/sd4/index.html[/url]
[url]http://growl.info/[/url]


Purpose:
This script takes events from the iCal calendars, and enters them as actions into the OmniFocus application.
The script will do the folling actions:
• Create an OmniFocus action with the name of the iCal event as the action name.
• Place the OmniFocus action into a single action project with the prefix: iCal- and add the calendar name. (iCal-Birthdays)
• Assign the OmniFocus action a context with the same name as the single action project
• Set the start date and end date of the OmniFocus action to the event start and end date.
• Add a unique id in the note in the action with the prefix: "iCal UID:" + the iCal event uid + start & end date unique id.
Example: (iCal UID: 7F3952B2-BB97-492A-B501-1013A1E0D4AC:20119160201191886340)
This ID is what allows the script to connect an iCal event with an OmniFocus action. If you mess with this ID it will either be deleted by the script or never deleted.

The script relies on iCalBuddy to be run. You'll need to download it and install it
[url]http://hasseg.org/icalBuddy/[/url]
Run the install.command file and follow the prompts in the terminal window.

The script only imports iCal events into OmniFocus actions. Changing any of the times on the actions will not do anything to iCal events. If you delete an OF action, and the iCal event is in the calendar,
the script will re-create the action.
Completing an OF action will remain completed. After the current time is beyond the action end time, the script is no longer checking that action.

The script will probably not perform as expected if you have two calendar's that are the same name.
The script will delete any OmniFocus action that has the characters
iCal UID:
in the note field.

After the single action projects and contexts have been created, you can move them wherever you want and they will stay there.

User bears all responsibility for running this script. Enjoy.

---10/09/2011
• added functionality to use Growl 1.3 notifications
• included helper script which copies the applescript to the users/library/scripts/applications/OmniFocus folder. This allows a user to right click on the toolbar, and add script to the OmniFocus toolbar

---Removed all other versions of the script. And uploaded the newest version to the top of the thread. The attachment below is the latest version.

SpiralOcean 2011-09-13 06:27 AM

Fixed a bug in the script that would re-create the single action project at the root levels if the user had moved the project into a folder.

After the single-action project has been created by the script, you can move it and new actions will be created in that project. The same for contexts.

To modify the times for an action that is managed by this script, change the event in iCal. Any changes in iCal will change the OmniFocus actions as long as they are within the 7 day window for events.

Simon Major 2011-09-30 01:46 PM

I am new to the forum and an IT dummy. I have just downloaded and run the script, and it shows an error message: 'invalid date and time date 09/30/11. - 30720.' This stopped the transfer of entries from iCal after the first 2. Can someone please advise as to what is going wrong? Thank you. PS I am in the UK, and I wonder if the dates are configured differently for UK users? I apologise if this is the wrong place to ask for this help.

SpiralOcean 2011-10-02 06:08 AM

I'll take a look at the iCalBuddy output.

If you run this applescript, it will place a file called:
iCalEventsToOmniFocusTroubleshooting.txt
on your desktop.

You can post the results here or send me a message with the results by clicking on my user name.

SpiralOcean 2011-10-09 06:24 PM

---10/09/2011
• added functionality to use Growl 1.3 notifications
• included helper script which copies the applescript to the users/library/scripts/applications/OmniFocus folder. This allows a user to right click on the toolbar, and add script to the OmniFocus toolbar

Simon Major 2011-10-21 12:54 PM

[QUOTE=SpiralOcean;102378]I'll take a look at the iCalBuddy output.

If you run this applescript, it will place a file called:
iCalEventsToOmniFocusTroubleshooting.txt
on your desktop.

You can post the results here or send me a message with the results by clicking on my user name.[/QUOTE]
Thanks. Sorry, which script?

Ah, wait, I have the events log in the applescript editor. I will email the details. Thanks

andrep 2011-10-22 04:16 AM

d/m/y date format
 
Hi all,

@SpiralOcean - Very useful script. Thanks a lot for sharing

@Simon Major: yes, it's a problem with the date format. You can make the script work by editing the one instance where the format is quoted in the script, thusly:

Right-click on the script, 'Show package contents', then navigate to Contents/Resources/Scripts/ and open main.scpt in the Applescript Editor. Change:

set shellScriptString to "/usr/local/bin/icalBuddy -ic \"" & calendarName & "\" -nc -nrd -eep \"url,location,notes\" -uid -df [B]\"%m/%d/%y\"[/B] eventsToday+" & daysToLookAhead

to:

set shellScriptString to "/usr/local/bin/icalBuddy -ic \"" & calendarName & "\" -nc -nrd -eep \"url,location,notes\" -uid -df [B]\"%d/%m/%y\"[/B] eventsToday+" & daysToLookAhead

There must be a more elegant way to fix this, but I don't know how...

SpiralOcean 2011-10-22 06:24 AM

I don't think this is a localization problem... I changed my date format and the script worked. I think it has to do with how the script is parsing out the text return from iCal.

For my machine there are 4 spaces in front of the date, the script was starting at position 4 to the end of the date to get the date. However, on Simon's machine, those spaces weren't there.

I've changed the script parsing a bit... Simon, give this one a shot and let me know if it works.

andrep 2011-10-23 02:44 AM

[QUOTE=SpiralOcean;103221]I don't think this is a localization problem... I changed my date format and the script worked. I think it has to do with how the script is parsing out the text return from iCal.

For my machine there are 4 spaces in front of the date, the script was starting at position 4 to the end of the date to get the date. However, on Simon's machine, those spaces weren't there.

I've changed the script parsing a bit... Simon, give this one a shot and let me know if it works.[/QUOTE]

Just tried the last version. Similar error to Simon: "Invalid date and time date 10/27/11. -30720". Am also in the UK too, btw.

SpiralOcean 2011-10-23 07:12 AM

Okay, so it probably is a localization thing...

This one should do the trick. Let me know if it doesn't work.

Also, Growl greatly enhances this script.
[url]http://growl.info/[/url]


All times are GMT -8. The time now is 10:47 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.