export iCal ToDo's per calendar to text or (better) into table/html

Hi,

First post, directly a question:

I want to be able to print a page with all my unfinished todo’s per calendar, preferably in column-view per agenda.
iCal itself can somehow print todo’s but makes a mess…
I know this is more or less possible with OmniOutliner, as posted here, but this doen’t work for me somehow.

what i need:
all unfinished todo’s from calendar A, B, C to H exported into textfile(s) (ordered alphabetically and per calendar) - so i can cut ‘n’ paste this into something printable

what i would love:
all unfinished todo’s from (in ical activated) calendars extracted and direclty placed into a table with a column for every calendar with todo’s iordered by priority and alphabetically. (with the result in in e.g. Numbers.app or as html) to print it out.

Thanks in advance!
Sibe Jan

Welcome. :slight_smile:

Try something like this:

set lf to ASCII character 10 -- line feed
set output to {}
set calList to {}
set todoList to {}

tell application "iCal"
	repeat with thisCal in calendars
		tell thisCal
			if todos is not {} then
				-- Get todos that have been completed within the last year.
				set pendingList to (summary of todos whose completion date > ((current date) - 52 * weeks))
				
				if pendingList is not {} then
					set end of calList to name
					set end of todoList to pendingList
				end if
			end if
		end tell
	end repeat
end tell

repeat with i from 1 to (count calList)
	set end of output to (item i of calList) & lf
	set end of output to (item i of todoList) & ""
end repeat

-- Join items in `output` into text (with line feeds)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to lf
set output to "" & output
set AppleScript's text item delimiters to ASTID

set the clipboard to output

The todos are not sorted. Also, more importantly, I don’t see any way to determine if a todo has been completed.

If a todo is completed (by checking the check box) the property completion date of the todo contains the date,
otherwise it’s empty

@ Bruce and Stefan. Great so far,! The script was very promising, but this completing issue is still to complicated for me to implement…
If that does work, i’ll be very glad! Implementing the name of the referred calendar on top of the list of todo’s is perfect, as well the fact that the notes in the todo are not extracted makes it far more useable than iCal’s printing output. Exporting it per calendar in an alphabetical order would still be welcome, but must be not that hard to do in numbers.app.
Thanks so far, guys!

I’ve edited my above script accordingly.

I tried using whose completion date is not missing vallue, but that didn’t seem to work. That’s why I’m comparing the completion date to an earlier date.

haha… now i only get todo’s which are completed already, but actually i want the todo’s which are not completed…
i tried to change some ‘not’ into ‘yes’, but the script didn’t work anymore…

Hi,

in case of iCal it’s tricky, because you can’t determine the empty property just with a comparison with missing value.
You have to assign the value to a variable. If the value is missing, the variable won’t be defined


set lf to ASCII character 10 -- line feed
set output to {}
set calList to {}
set todoList to {}

tell application "iCal"
	repeat with thisCal in calendars
		set pendingList to {}
		tell thisCal
			repeat with oneTodo in todos
				set a to completion date of oneTodo
				try
					a -- throws an error if completion date is empty
				on error
					set end of pendingList to summary of oneTodo
				end try
			end repeat
			if pendingList is not {} then
				set end of calList to name
				set end of todoList to pendingList
			end if
		end tell
	end repeat
end tell

repeat with i from 1 to (count calList)
	set end of output to (item i of calList) & lf
	set end of output to (item i of todoList) & ""
end repeat

-- Join items in `output` into text (with line feeds)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to lf
set output to "" & output
set AppleScript's text item delimiters to ASTID

set the clipboard to output

Woaw! This works beautifully! You guys have stopped me from being and getting frustrated about stupid manually changing data - finally!
Thanks very much, StefanK and Bruce!

Only thing for me to find out now is to then into rows in numbers.app and have each row independently ordered alphabetically.

regards,
sibe jan

@ StefanK and Bruce.
Are you allright with me sharing this script on the forum of ActionTastic?

That’s fine with me.

with me too :slight_smile: