Move events by event name/summary/title

I have just moved from pc to mac and really miss autoformat in outlook.

I run my business from my mobile and all my calendar events were colour formatted according to title. sorry if this script already exisits but i cant find it any where…

I would like all events that include the word driving in them to be moved to the driving calendar, all events including the word test to the test calendar etc. (and when they dont include those words to move to unconfirmed.)

i found this script which moves everything, although i can only get it to work with calendar numbers not names!

tell application "iCal"
	get (event of calendar 1) move to end of events of calendar 3
end tell

I have tried this but get “iCal got an error: Can’t get every event whose summary contains “driving”.”

tell application "iCal"
	get (events whose summary contains "driving") move to end of events of calendar 1
end tell

please help

thanks

Martyn

Model: imac
Browser: Firefox 3.0.6
Operating System: Mac OS X (10.5)

Hi,

try this, it moves all events of calendar sourceCalendar which contains each word of keywordList to the appropriate calendars


property sourceCalendar : "home"
property keywordList : {"driving", "test"}

tell application "iCal"
	repeat with oneKeyword in keywordList
		move (events of calendar sourceCalendar whose summary contains oneKeyword) to end of events of calendar (contents of oneKeyword)
	end repeat
end tell

Hi,

Events are contained by calendars, so you have to refer to a calendar. Something like this should work:

tell application "iCal"
	get (events of calendar "Home" whose summary contains "driving") move to end of events of calendar "Driving"
end tell

Best wishes

John Maisey
www.nhoj.co.uk

Thank you both for your replies

both scripts work very nicely, but when i get to the next step I run into a problem… if i change the event ‘which happens a lot working with teenagers’ the script doesn’t remove the change from the calendar. Ive had a play and I think the script needs to look like this

property sourceCalendar : "home"
property keywordList : {"driving", "test", "life"}

tell application "iCal"
	repeat with oneKeyword in keywordList
		move (events of calendar sourceCalendar whose summary contains oneKeyword) to end of events of calendar (contents of oneKeyword)
		move (events of calendar whose summary does not contain oneKeyword) to end of events of calendar "home"
	end repeat
end tell 

however the the script replies “Can’t get every event of calendar”.

If i could get over this step i will be a very happy man

thanks again

Martyn

you have to specify the calendar

 move (events of calendar sourceCalendar whose summary does not contain oneKeyword) to end of events of calendar "home"

but be careful with this line, in the first iteration will move all events to calendar “home” which don’t contain “driving”,
that means all events are affected, which contain “test” or “life”, but not “driving” !

Thanks for the quick reply

but now i’m confused! sorry only started with apple script a couple of weeks ago.

ive tried this aswell but no luck get back “iCal got an error: Can’t make {every event of calendar “driving” whose summary does not contain “driving”} into type reference.”


property sourceCalendar : "home"
property sourceCalendar2 : "driving"
property keywordList : {"driving", "test", "life"}

tell application "iCal"
	repeat with oneKeyword in keywordList
		move (events of calendar sourceCalendar whose summary contains oneKeyword) to end of events of calendar (contents of oneKeyword)
		move {events of calendar sourceCalendar2 whose summary does not contain oneKeyword} to end of events of calendar "home"
	end repeat
end tell

so which is the best way around this?

thanks Martyn

use parentheses () instead of braces {} in the second line

getting there!

property sourceCalendar : "home"
property sourceCalendar2 : "driving"
property sourceCalendar3 : "test"
property keywordList : {"driving", "test", "life"}

tell application "iCal"
	repeat with oneKeyword in keywordList
		move (events of calendar sourceCalendar whose summary contains oneKeyword) to end of events of calendar (contents of oneKeyword)
		move (events of calendar sourceCalendar2 whose summary does not contain "driving") to end of events of calendar "home"
		move (events of calendar sourceCalendar3 whose summary does not contain "test") to end of events of calendar "home"
	end repeat
end tell

the problem now is things are moving from calendar

then run the script again

thanks

martyn

with this syntax the second and third line in the repeat loop are useless,
because they don’t depend on the keyword list.
Try this


property sourceCalendar : "home"
property sourceCalendar2 : "driving"
property sourceCalendar3 : "test"
property keywordList : {"driving", "test", "life"}

tell application "iCal"
	repeat with oneKeyword in keywordList
		move (events of calendar sourceCalendar whose summary contains oneKeyword) to end of events of calendar (contents of oneKeyword)
	end repeat
	move (events of calendar sourceCalendar2 whose summary does not contain "driving" and summary does not contain "test") to end of events of calendar "home"
end tell

You are a God! it works perfectly

Can a script run continually in the background or does it have to be run manually started each time. Can the script open when ical opens, or whenever a synchronization occurs?

thank you so much for this :cool:

Martyn

running this script continuously in the background is a waste of time and CPU.
Isn’t it sufficient to run it once when the computer starts up?.
If yes, save the script as application (bundle) and put in the startup items.

sounds good to me

thanks for all your help today

do you except donations?

martyn

You’re welcome.
There’s no donation needed for a 5 minute effort :wink:

well thanks again

Martyn