iCal edit/ modify Todo items with applescript

Joined
Aug 3, 2013
Messages
3
Reaction score
0
Points
1
I am trying to create an applescript that will automatically change to the priority of the todo list item based on the due date.
The close it is to the due date the priority would change.

I have an applescript that people can send me appointments via email. I use icalbuddy to display them on the desktop with geektool.

I have used a do shell script command that get the uid (unique todo id key) which is below from icalbuddy

Code:
 set theUids to do shell script "/usr/local/bin/icalBuddy -nc -uid  uncompletedTasks|grep uid|sed -e 's/u[^:]*://'"

I found a script that finds iCal events with the uid but dont know how to modify it for todo list items

Code:
tell application "iCal"    tell calendar "Home"       set theEvent to first event whose uid = "1BCA3512-F3A9-4BCB-A0FD-BE812968D371"    end tell end tell

thanks in advance for any help
 
OP
W
Joined
Aug 3, 2013
Messages
3
Reaction score
0
Points
1
as I said in the post above I am trying to create an applescript that will automatically change to the priority of the todo list item based on the due date.

I have found an application called Things that is scriptable.

I also have the script addition Satimage.osax which has some useful commands.

I have started the applescript using Things at the moment I have it sorting the to do by priority.
I would like it to sorted them by date and if there are two with the same date then to look in the notes of the to do where I put the time and sort them by time.

The code below is what I have so far which sorts them by priority.

Main
Code:
tell application "Things"
	try
		close window "Things"
	end try
	set thelist to {}
	set theToDos to to do of list "today"
	set theCount to count theToDos
	repeat with i from 1 to theCount
		set ToDo to to do i of list "today"
		
		set thename to name of ToDo
		set theduedate to due date of ToDo
		set theduedate to date string of theduedate
		set thenote to notes of ToDo
		set thepriority to tag names of ToDo
		
		set theToDo to "• " & thename & return & "due: " & theduedate & return & thenote & return & "priority: " & thepriority & return
		
		set end of thelist to theToDo
		
	end repeat
	set listCount to count thelist
	set new_list to {}
	repeat with f from 1 to listCount
		set itemlist to get item f of thelist
		set lastword to last word of itemlist
		
		if lastword is equal to "High" then
			set beginning of new_list to itemlist
			
		else if lastword is equal to "Medium" then
			set end of new_list to itemlist
			
		else if lastword is equal to "Low" then
			set end of new_list to itemlist
			
			
		end if
		
		
		
	end repeat
	
	
	
	
	
	
	
	tell application "Finder"
		activate
		display dialog new_list as string buttons {"OK"} default button 1
	end tell
end tell

the code below can be used to extract to time from the notes as I put other information in the notes as well as the time in this format 14:00.
Code:
set theOffset to offset of ":" in thenote
set num to theOffset - 2
set thetime to text (theOffset + 2) thru num of thenote
set thehours to characters 1 thru 2 of thetime as string
set themins to characters 4 thru 5 of thetime as string

here is the command to set the priority in things below
Code:
set tag names of ToDo to "High" --"Medium" or "Low"
the ToDo is a variable I set in the main code above.

thanks for any help
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top