From an ics file thru its event entry inside Calendar.

Hello and thanks in advance for your help !

Using AppleScript on Mavericks, I’m trying to “coerce” (I think) an .ics file from the finder to its ‘Calendar Event’ class item. Preferably, it won’t be a droplet that use the Folder Action mechanism.

Ideally, I would like to do something like:

set myItem to the Event referred by thePosixPathToMyFile as Event

But of course, it didn’t work and I just can’t figure out how to do it.

My goal is then to use the Calendar’s applescript dictionary. In short, instead of starting from within the Calendar app, I simply want to start from the HD file.

Any help will be appreciated !

No answer yet. :frowning:

But here’s the things I’ve tried this morning:

  • So, I know the path to my .ics files. This text info can be provide to my applescript as a parameter.
  • Then, I know it’s a primitive process, but I simply open this file from a Tell Application “Calendar” block.
  • Since the correct event is now highlighted inside the Calendar app, I guess it will be easy to retrieve this selected UIElement (the Event).
  • Then, I’ll probably be able to control the content of this found event by using UI scripting !?

Its not exactly what I want because I would of course prefer to use the Calendar applescript dictionary instead of UI scripting… So, I’m just missing a small part which is the actual applescript item/element/class which is inside application/calendars/events.

How can I fill the gap between a file and its representation inside the Calendar app ? OR maybe asked differently, how can I retrieve (and set) a Calendar event by searching its physical file name ??

Thanks again for your help !

Hi forg99,

Coercion is only done in the language. What you want to do is import the ics file into Calendar.


I see what you’re trying to do. You’re trying to coerce a Finder reference into a reference that you can use?

Thank you Kel1 for your reply ! Yes, that’s what I’m trying to do and I actually succeed with this very simple command:

set myEvent to events in calendar "Work" where uid is "FD5C38C4-62E6-4FE9-A94B-6C8275B86AEC"

. Luckily, this dictionary UID property inside the Calendar app contains the corresponding .ics filename on the disk. In this case, my file is named “FD5C38C4-62E6-4FE9-A94B-6C8275B86AEC.ics”

I’m almost done but I stuck with another problem. :frowning: Because I need the equivalent thing for the Reminders app (always on Mavericks).

Unfortunately, in Reminders, the dictionary ID property (not UID as in Calendar) seems to have nothing to do with the corresponding filename. Maybe there’s a bug in Reminders and/or in its applescript dictionary !? Or maybe it’s working differently in the Reminders app !?
I’m just unable to retrieve a Reminder by using my ‘key’. Which is: myFilename = (UID & “.ics”)

Any idea ?

Responding to myself. :slight_smile:

So, because an applescript command like this is not working in Reminders:

set myReminder to reminders in list "Work" where id is "A526EF6E-DA8F-452C-B66A-E048E30A5D4E"

while the equivalent is working very well in Calendar, I’m still stuck at this point.

If I use the Finder to find the file (using my known .ics filename), then to open the targeted Reminder, I can use UI scripting to control most elements of my Reminder. It works but it’s not very clean…

My other workaround would be to open the .ics file for write access and to work directly inside the file. But I think this solution is not cleaner than UI scripting.

Since I can’t use the Reminder’s dictionary to retrieve my Reminder by using its physical filename, I have no idea how to get satisfaction. Is it possible to use the Document and/or the File classes ? If so, how can I do it ?
Is there another (maybe a low-level hidden) trick that I’m not aware of ?

I’m not a professional applescripter and I need your lights ! Is my “retrieve a Reminder by its filename” operation can be done ??

Thanks again !

Hi forg99,

It has been a while, but what if you ‘open’ the ics file with Calendar?

Edited: I think I remember now. You don’t want to use ui scripting. Think there was a way.


Here’s an old post:
Haven’t looked through it but you need to change the app name right off the bat.

I seem to remember that you can do it by switching files in the folder for Calendar. Will be looking into this.


Hi forge,

I think I was responding to the wrong post. On rereading your post I think it can be done.


I remember now. You want to swap out the files in the place where the ics files are stored. I haven’t tried it in Mavericks. It used to be a bit flakey in Jaguar, but now might work.

The part the didn’t work well was in the updating in Calendar. You might find a solution in Mavericks, but I don’t know.


Thanks again kel1 !

Ok, I’m gonna forget about this for now. Hopefully, this problem/bug, inside the Reminders applescript’s dictionary, will be fixed in the future.