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

Make uneditable events in iCal editable Apps
I recently synchronized my Facebook events with my Google calendar, and then I added that calendar to iCal via CalDAV. When I want to add one of those events to one of my published calendars on my website, I always try to copy the event from the Facebook events calendar and paste it in the other calendar.

However, I usually want to edit the event which sometimes causes all sorts of headaches because it's either not editable (even though I'm editing a copy in my own calendar) or it wants to send emails to all my invitees. This is due to the fact that I am not recognized as the event's organizer. So I devised a rudimentary way to make such copied events editable and hassle free. My solution is crude and slightly convoluted, so I am hoping someone out there will post a better version in the comments.

Basically, I used a Folder Action to obtain an .ics file of the single event, edit it to remove the ORGANIZER field, and then open the edited file.

First, you'll have to create a convenient folder to drag your events to and attach the following AppleScript:
on adding folder items to this_folder after receiving added_items
  
  repeat with i from 1 to number of items in added_items
    set this_item to item i of added_items as alias
    tell application "Finder"
      --get the name of the file
      set pathstr to POSIX path of this_item
      --set this_file_name to the name of this_item
      set exT_name to name extension of this_item
    end tell
    if the exT_name is "ics" then
      set cmd to "grep -v ^ORGANIZER: '" & pathstr & "' > '" & pathstr & ".tmp'; mv '" & pathstr & ".tmp' '" & pathstr & "'"
      display dialog cmd buttons {"OK"} default button 1 default answer "" with icon 2
      do shell script cmd
    end if
    tell application "Finder"
      open this_item
    end tell
    
  end repeat
  
end adding folder items to
I created a folder called MakeEventsEditable, put it in a handy spot, enabled Folder Actions, and then attached my script.

One caveat on the next step -- events in a subscribed Facebook events calendar cannot be dragged to a folder, so to get around this, you have to Control+click on the event and select 'Mail Event.' This will bring up an email with the ics file attached. Drag that attached event file to your folder with the attached Folder Action.

It will create a temporary file with the edited contents and then replace the old version with the new. If someone knows how to do a safe clean-up of the file after it's been added to iCal, please edit the script for me and post it in the comments.

The script will then open the edited event in iCal, which will prompt you to select a calendar to add it to. Note, if you add it to a Google calendar via CalDAV, sometimes the event will disappear in a few seconds. To bring it back, refresh that calendar. This works reliably for me.

Now you have an editable event. Every once in awhile, you'll have to clean out that folder. I'm going to be using this a lot. If you find you are having trouble with any events using this script, there may be other fields in the file that will need to be edited or removed as well.

[crarko adds: I haven't tested this one.]
    •    
  • Currently 4.00 / 5
  You rated: 5 / 5 (6 votes cast)
 
[4,158 views]  

Make uneditable events in iCal editable | 4 comments | Create New Account
Click here to return to the 'Make uneditable events in iCal editable' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make uneditable events in iCal editable
Authored by: karog on Jun 20, '11 08:33:18AM
Two minor code comments:

1) You can simplify the initial repeat as

repeat with this_item in added_items

Also the added_items are already aliases.

2) You do not need exT_name. Instead you can simply do

if pathstr ends with ".ics"


[ Reply to This | # ]
Make uneditable events in iCal editable
Authored by: scottbayes on Jun 20, '11 08:11:30PM
Doesn't this LaunchAgent prevent you from logging out? Every time you try to log out, Stickies relaunches and blocks the logout.
Well, if the following comment in the original article is true, it won't be a problem, though I haven't tested it yet:
If fact, in order to quit the app at any time other than logout or shutdown you'll need to disable the job
This could be an incredibly useful hint for me, one of the better ones I've seen on Mac OS X H.

[ Reply to This | # ]
Make uneditable events in iCal editable
Authored by: scottbayes on Jun 20, '11 08:19:21PM

Aaaarrrggh! Posted previous comment against wrong hint; meant to post against "Always keep an application open - Mac OS X Hints".

This site makes quoting other text very difficult, though I may not know some strong magic that would ace it.

If you could put the posting form at the bottom of the hint page (with ONLY that hint on it), I could copy and paste at will. After I logged in to post while viewing the hint, I got put on a page with more than one hint on it or something like that, hard to reconstruct the sequence. Anyway posted against wrong one.



[ Reply to This | # ]
Make uneditable events in iCal editable
Authored by: robleach on Jun 22, '11 10:48:04AM
I forgot to take out the dialog message I was using for debugging, so here's the script without that, a little tidying up, a fix for some file formats which list the ORGANIZER line as 'ORGANIZER;' instead of 'ORGANIZER:', and a fix for the finder trying to open the .tmp file because I hadn't put the open_this_item in the if block:
on adding folder items to this_folder after receiving added_items
	
	repeat with i from 1 to number of items in added_items
		set this_item to item i of added_items as alias
		tell application "Finder"
			--get the path of the file
			set pathstr to POSIX path of this_item
			set exT_name to name extension of this_item
		end tell
		if the exT_name is "ics" then
			set cmd to "grep -v ^ORGANIZER '" & pathstr & "' > '" & pathstr & ".tmp'; mv '" & pathstr & ".tmp' '" & pathstr & "'"
			--display dialog cmd with icon 2
			do shell script cmd
			tell application "Finder"
				open this_item
			end tell
		end if
		
	end repeat
	
end adding folder items to
Also, I've noted that sometimes I get an error from iCal when I choose to add the event to a google calendar synced via calDAV that asks me to either revert to server or go offline. Reverting to server deletes the added event, so what I've done to get around this is to go offline, edit the event, then cut and paste it onto a non-google calendar, refresh the google calendar, then paste the event back into the google calendar. For some reason, that worked when importing did not.

Rob
Edited on Jun 22, '11 11:22:47AM by robleach


[ Reply to This | # ]