Need a unique iCal script

Hello,

I am a long time Mac user but have never ventured into scripts at all. I have searched around for an existing solution to my dilemma but I can’t seem to find any.

I need to keep track on a iCal calendar of a moving block of time. The block of time is always moving 7 to 12 weeks (49-84 days) from the current day. So basically I need a script that automatically runs every morning that puts a event on my calendar that starts 7 weeks from the current day and the duration of the event is 5 weeks. But then each repeating day the script would either need to move the existing event a day ahead to remain 7 weeks out or delete the other one and create a new one. Not sure if this is possible and if so how.

The reason for this is that I have entered into a scheduling agreement with an agency that claims that window for themselves. I am free to schedule myself from 7 weeks in, and from 12 weeks out.

I hope I have followed the rules and made myself clear. Thank you for any help.

Paul

Shaboyagan, welcome to MacScripter!

Here’s a simple script that should do what you want:

property summaryEvent : "event name here"
property calendarEvent : "calendar name here"

tell application "iCal"
	tell calendar calendarEvent
		try -- to find & delete current event, allow nonexistence
			delete (first event whose summary is summaryEvent)
		end try
	end tell
end tell

set now to current date
set startDate to now + 7 * weeks
set endDate to now + 12 * weeks

tell application "iCal"
	tell calendar calendarEvent -- to create the new event
		make new event with properties {summary:summaryEvent, start date:startDate, end date:endDate, allday event:true}
	end tell
end tell

Usage
Click “Open this Scriplet in your Editor”, above. AppleScript Editor will open, and the script will appear in its window.
At the top are 2 lines beginning with “property”, followed by some text in quotes. Replace these texts with, respectively, the name of the event and the name of the calendar where it should appear. The quotes should remain!
Save the script to the desktop, with any name that suits you.

Open menu AppleScript Editor>Preferences>General. In that pane click Show script menu in menubar. A black script icon should appear at the rightmost end of the menubar.

Now change to iCal, and go the script menu> Open scripts folder>Open folder with iCal scripts. Drop the saved script into the folder window which opens.

Now, when in iCal, you can go to the script menu, and you will see the script. Simply select to have it run.
If it does not appear, or does not seem to run, you might need to logout and back in.

Note that my Mac runs Dutch, so the menu names might not be 100% exact.
And possibly you have “Calendar”, not “iCal”.

alastor933,

That is absolutely amazing!! That is exactly what I needed! I set up a ical daily event that will open and run that script file. That will test for the first time tomorrow morning and should work fine. At that point it will be perfect.

I cannot thank you enough for taking the time to help me and in such a detailed way. I really appreciate it!!

Paul