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


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: 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 | # ]