Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add To Dos to iCal from a text file using AppleScript Apps
I sometimes keep a list of To Dos in text files or Stickies, since I'm not a big user of calendar apps. However, I'm leaving on a trip and needed to sync my To Dos with my cell phone, so I decided to create an AppleScript that reads a text file and converts each line into an iCal To Do item. When running it you just need to specify the text file to read. It will add ToDos to the Home calendar, but that's easy to change. Here's the code:
tell application "iCal"
  set myFile to (choose file with prompt ¬
   "Select a text file to read for To Dos:" of type {"TEXT"})
  open for access myFile
  set myFileContents to read myFile
  close access myFile
  set the paragraph_list to every paragraph of myFileContents
  repeat with i from 1 to the count of paragraphs of myFileContents
    set thisTodo to paragraph i of the myFileContents
    if (thisTodo is not "") then
      set newtodo to (make new todo at end of ¬
       todos of calendar "Home")
      tell newtodo
        set priority to high priority --optional
        set summary to thisTodo
      end tell
    end if
  end repeat
end tell
Please note that I'm a casual AppleScript user, so there might be a better way to do this, but this works for me.
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[10,920 views]  

Add To Dos to iCal from a text file using AppleScript | 5 comments | Create New Account
Click here to return to the 'Add To Dos to iCal from a text file using AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add To Dos to iCal from a text file using AppleScript
Authored by: LeeH on Feb 20, '07 12:10:34PM

You might want to consider Event Maker. It is free, available at MacUpdate and lets you add To Do's or Events to any iCal calendar you have. Very nice program



[ Reply to This | # ]
Add To Dos to iCal from a text file using AppleScript
Authored by: DotDotComma on Feb 20, '07 02:22:41PM

Nice little idea, and a timely reminder that I've always meant to get deeper into Applescript (need to find how to make default due date the next day .... )

Yes, Event Maker is useful too - I've even paid for it! - but this is a great quick way of taking jottings of tasks that need doing and transforming them into ToDos in Ical ... faster than Event Maker could do but with less detail ....

When I crank up Applescript skills to the dizzy heights of setting due dates and alarms, then this will be even better .

Thanks



[ Reply to This | # ]
Add To Dos to iCal from a text file using AppleScript
Authored by: osxpounder on Feb 20, '07 03:20:56PM

Being able to set the alarms and due dates on To Dos and Events via AppleScript would be super helpful, because I have "sets" of alarm prefs, depending on whether the event's for work, for home, to be shared, etc. Cool idea. Thanks for sharing this hint, too!



[ Reply to This | # ]
Add To Dos to iCal from a text file using AppleScript
Authored by: smoohova on Feb 22, '07 10:13:16AM

Here's a script that I modified from the Quicksilver Forums:

set iCalendars to {}
set theCals to {}
set priList to {"None", "Very Important", "Important", "Not Important"}
set priNums to {0, 3, 5, 9}

tell application "iCal"
set theCals to calendars whose writable is true
repeat with i from 1 to count of theCals
copy title of item i of theCals to end of iCalendars
end repeat
end tell


tell application "Quicksilver" to activate
display dialog "Enter toDo Summary: " default answer ""
set theSummary to the text returned of the result

display dialog "Enter toDo Description:" default answer ""
set theDescription to the text returned of the result

set theChoice to choose from list iCalendars with prompt "Choose the Calendar to use" OK button name "Choose" without multiple selections allowed and empty selection allowed

if theChoice is not false then
set theCalChoice to item 1 of theChoice
end if

set theCalName to theCalChoice



-- Run through our Calendar list and find the iCal id of the chosen Calendar
set i to 1
repeat with anitem in iCalendars
if item i of iCalendars is equal to theCalName then
set theNum to i
exit repeat
end if
set i to i + 1
end repeat

set currentCal to item theNum of theCals

tell application "iCal"
make todo at end of todos of currentCal with properties {priority:3, summary:theSummary, description:theDescription}
end tell


First, it will ask you to put the title of the Todo, then it will ask if you want to put any notes in it, and then it will finally display a list of calendars you have that you want to add the todo to.



[ Reply to This | # ]
Add To Dos to iCal from a text file using AppleScript
Authored by: johnga1t on Feb 23, '07 09:51:19AM
for those who work in the terminal a lot and find keystrokes more friendly than mouse clicks, here's a quick hack. try something like:

./todo personal "check this out" "current date+1*hours"
typing
./todo
without any arguments will show usage information.

#!/bin/bash

DEFAULT_ALARM='current date + 1*days'

if [ $# == 0 ]
    then
    echo
    echo usage: 
    echo
    echo "  "`basename $0` calendar_name todo_description [due_date]
    echo
    echo due_date is an optional alarm time in applescript date specification. c
onvenient dates might be \"current date + 2*hours\" or \"current date + 5*days\"
, etc. see http://tinyurl.com/26fj2s for more information on date formats.
    echo

    exit
else
    cal=$1
    todo=$2

    if [ $# == 3 ]
        then
        alarm=$3
    else
        alarm=$DEFAULT_ALARM
    fi
fi

foo=`osascript <<EOF
  tell application "iCal"
    set newtodo to (make new todo at end of todos of calendar "$cal")
    tell newtodo
      set summary to "$todo"
      set due date to ($alarm)
      make new sound alarm at end with properties {trigger:($alarm)}
      set foo to ($alarm as text)
    end tell
  end tell
EOF`
status=$?

if [ $status == 0 ]
    then
    echo \"$todo\" scheduled on calendar \"$cal\" due $foo
else
    echo error: failed to schedule todo
fi


[ Reply to This | # ]