Previous 1 2 Next 19 Replies Latest reply: Jan 31, 2013 4:20 PM by John Maisey Go to original post
  • John Maisey Level 5 (6,895 points)

    The forum's greedy emoticons stole a :( from the script.




    -- John Maisey -- -- 21 Feb 2012
    -- Modified 1 Mar 2012 
    set {myList, myCount, myFailures, calName} to {{}, 0, 0, "Recovered Events"}
    tell application "Finder" to set myPath to choose folder default location (path to desktop)
    set theFolders to my getSubFolders(myPath, {myPath})
    tell application "System Events"
              repeat with myFolder in theFolders
                        set myFiles to (files of myFolder whose name extension is "icalevent")
                        repeat with thisFile in myFiles
                                  set end of myList to (value of property list file (POSIX path of thisFile))
                        end repeat
              end repeat
    end tell
    tell application "iCal"
              if name of calendars does not contain calName then make new calendar with properties {name:calName}
              repeat with myEvent in myList
                                  set thisEvent to make new event at the end of events of calendar calName with properties {start date: (dueDate of myEvent), end date: ((dueDate of myEvent) + 1 * hours)}
                                            set summary of thisEvent to |summary| of myEvent
                                  end try
                                            set description of thisEvent to comment of myEvent
                                  end try
                                            set allday event of thisEvent to fullDay of myEvent
                                  end try
                                  set myCount to myCount + 1
                        on error theErr
                                  set myFailures to myFailures + 1
      display dialog theErr
                        end try
              end repeat
              display dialog (myCount & " of " & (myCount + myFailures) & " events recovered to iCal") as text buttons {"OK"} default button "OK" with title "data recovery" with icon 1
    end tell
    on getSubFolders(myPath, mySet)
              tell application "System Events"
                        set myArray to folders of myPath
                        repeat with myItem in myArray
                                  set mySet to my getSubFolders(myItem, mySet)
                                  set end of mySet to (path of myItem) as alias
                        end repeat
              end tell
              return mySet
    end getSubFolders
  • MrMur Level 1 (0 points)

    Holy smoke, John, it worked! Ran like a top! Your magic script took all those iCal files and plugged the info into all the dates. I now have valuable reference points in my calendar going back to 2006 -- kind of like a personal history refresher course!


    I am both in awe and in your debt. I suspect you took much time to figure out that scripts, and I am very grateful. If you plan to be in the States at some point, I will buy you a pint.



  • John Maisey Level 5 (6,895 points)

    I'm glad you found it helpful.


    MrMur wrote:

    If you plan to be in the States at some point, I will buy you a pint.

    I'll have to take you up on that some day.

  • GaleK14 Level 1 (0 points)

    Hey John,


    I am having a similar problem and hoped you might be able to assist. I am x-fering all of my data from my MacBook OS X (V 10.4.11) to my new MacBookPro (V.10.8.2) I have been able to move over all of my data, but I am having issues importing my iCal .ics file. I have tried exporting "home.ics" and "corestorage.ics" when I import them onto the new laptop I receive the following error "Calendar can't read this calendar file. No events have been added to your calendar." Additionally, the laptop is rather old so it does not have iCloud so I cannot move over the files in that manner, I have tried both veritations of your script and have received the following error "0 of 0 events recovered."


    Lastly, iCal on old laptop is v 2.0.5 and Calendar on new MacBookPro is v 10.8.2


    Thank you in advance,



  • John Maisey Level 5 (6,895 points)

    Hi Gale,


    The scripts above are for a particular type of file that iCal used to make, not .ics files.  It will not work on .ics files.


    It is going to be hard to find out what is stopping your .ics files transferring without looking at them.


    You could try making a calendar on the old machine with a single event in and exporting the calendar and re-imorting it into Calendar on the new mac.  If that works it os probably due to some corruption in the data of the other files.


    Best wishes


    John M

Previous 1 2 Next