ICal move events from one calendar to another with AppleScript

I made an AppleScript to clean up my calendars and thought I would share. My iMac had a calendar called "Home" and my iPhone had a default calendar "Calendar" so I ended up with all of my events spread across two calendars. Decide to clean up and move everything to one calendar.
This script is admittedly not very efficient. The nested repeat loops means it takes a while to run. Feel free to take this as a start point. I have it checking each property for missing value before adding it to avoid errors. I could have added a line to delete the old event after creating the copy, but I was just deleting the whole old calendar after the script ran.
I hope this is helpful to someone. Oh, this was created under Snow Leopard so if you are in Lion you might need to tweak things. I don't know how much the scripting library has changed.
tell application "iCal"
          set thisCalOld to calendar "OldCalendarName"
          set thisCalNew to calendar "NewCalendarToMoveEventsTo"
          set cntrMatch to 0
          set cntrCopied to 0
          repeat with thisEventOld in events of thisCalOld
                    repeat with thisEventNew in events of thisCalNew
                              set isOKtoProceedWithCopy to true
                              if (start date of thisEventNew = start date of thisEventOld) and (summary of thisEventNew = summary of thisEventOld) then
              --Don't copy
                                        set cntrMatch to cntrMatch + 1
                                        set isOKtoProceedWithCopy to false
                                        exit repeat
                              end if
                    end repeat
                    if isOKtoProceedWithCopy then
                              set theStamp to stamp date of thisEventOld
                              set theAllDay to allday event of thisEventOld
                              set theURL to url of thisEventOld
                              set theRecur to recurrence of thisEventOld
                              set theEndDt to end date of thisEventOld
                              set theClass to class of thisEventOld
                              set theStartDt to start date of thisEventOld
                              set theDesc to description of thisEventOld
                              set theSummary to summary of thisEventOld
                              set theLoc to location of thisEventOld
                              set theExcludeDt to excluded dates of thisEventOld
                              set theSeq to sequence of thisEventOld
                              set theStatus to status of thisEventOld
                              tell thisCalNew
                                        set thePropList to {}
                                        if theStamp is not equal to missing value then
                                                  set thePropList to thePropList & {stamp date:theStamp}
                                        end if
                                        if theAllDay is not equal to missing value then
                                                  set thePropList to thePropList & {allday event:theAllDay}
                                        end if
                                        if theURL is not equal to missing value then
                                                  set thePropList to thePropList & {url:theURL}
                                        end if
                                        if theRecur is not equal to missing value then
                                                  set thePropList to thePropList & {recurrence:theRecur}
                                        end if
                                        if theEndDt is not equal to missing value then
                                                  set thePropList to thePropList & {end date:theEndDt}
                                        end if
                                        if theClass is not equal to missing value then
                                                  set thePropList to thePropList & {class:theClass}
                                        end if
                                        if theStartDt is not equal to missing value then
                                                  set thePropList to thePropList & {start date:theStartDt}
                                        end if
                                        if theDesc is not equal to missing value then
                                                  set thePropList to thePropList & {description:theDesc}
                                        end if
                                        if theSummary is not equal to missing value then
                                                  set thePropList to thePropList & {summary:theSummary}
                                        end if
                                        if theLoc is not equal to missing value then
                                                  set thePropList to thePropList & {location:theLoc}
                                        end if
                                        if theExcludeDt is not equal to missing value then
                                                  set thePropList to thePropList & {excluded dates:theExcludeDt}
                                        end if
                                        if theSeq is not equal to missing value then
                                                  set thePropList to thePropList & {sequence:theSeq}
                                        end if
                                        if theStatus is not equal to missing value then
                                                  set thePropList to thePropList & {status:theStatus}
                                        end if
                                        set theNewCopy to make new event at end with properties thePropList
                              end tell
                              set cntrCopied to cntrCopied + 1
                    end if
          end repeat
end tell
display dialog ("Exists(not copied):" & cntrMatch & "  New Copied:" & cntrCopied)

That should not be necessary because I get the value of ID out of another table, where I generate ID with a sequence..
So normally it should just tranfer that row from one table to another. But it doesn't !
Knowing that I cannot create a row in the table wouter_published_posts(I can just move rows from the add_post table to the wouter_published_posts table), It should be inpossible that twice the ID appears. But yet he keeps trowing errors...
help me, please

Similar Messages

  • Moving events from one calendar to another

    Is it possible to move events from one calendar to another?
    Here is our scenario:
    User abc123 has set up a calendar abc123:boardroom for other users to book slots in the board room (he didn't know about resource calendars at the time and so didn't request one be created).
    Now abc123 is leaving the company, so his calendars are going to disappear, along with all the bookings for the board room.
    So my question is, can these events (and tasks) be moved to another calendar?
    I've tried creating a resource calendar and exporting/importing the calendar data, but this appears to leave the organizer of each event set as abc123:boardroom, with the result that the owner of the new resource calendar cannot modify the imported events.
    Maybe I'm missing something blindingly obvious here, but there doesn't seem to be any way to actually move events from one calendar to another. Does anyone have any advice as to how I might achieve this?
    Many thanks in advance.
    Regards,
    Mike.

    here is one way:
    Click on a meeting to get a Compose window. In the upper right Calendar box, click on the dropdown icon and select the calendar you want to move to from the list. Click on OK to save.
    Of course, if you have a lot of meetings to move, this will be a pain, but it does work.
    Note: before you do this, make sure you are an "owner" of the calendars(s) you want to move meetings to (or otherwise have access), and are subscribed to those calendars.

  • Can you move events from one drive to another easily?

    I've just bought an external firewire drive to dedicate to my Sony HD camcorder material.
    I've only imported 30 mins or so of stuff onto the Mac's internal drive with iMovie '08, and would like to know if anyone's managed to easily copy 'events' from one drive to another to merge/split content.
    Is it just a case of copying event folders from the iMovie Events folder to the external drive, but if so do you have to specify a particular path?
    Similarly, can you just move the individual 'Projects' or archive to DVD etc as they will invariably take up lots of space for longer footage? Does the projects file just hold references to the assembled clips, in which case moving events would scupper things as I seem to have several movie files in there already though these may just be things I uploaded to .Mac to test out.
    This may all be a bit of trial and error. Hopefully clips are only references unlike the pretty huge but self-contained iMovie 6 HD project packages. This also raises issues about how to easily backup all your 'events'.
    AC

    Observation:
    Just imported 15mins of video from the Sony.
    When you click import you are asked which drive to save to.
    As well as the Mac's internal drive, all my attached USB drives which are formatted as Mac OS Extended (journaled) appear as targets to save to as well as teh Firewire drive.
    I selected the Firewire drive and don't recall an option to create a sub-folder. After import a new top level folder of iMovie Events was created, but no others.
    Presumably iMovie Projects/Shared folders only exist on the boot drive.
    I'm assuming that this structure will allow you to share movie Events between Macs using external drives.
    Again, an assumption but I suspect iMovie scans all available suitable hard drives and checks what content is available in top level iMovie Events folders for non-boot drives as well as this folder in the user's Movies folder.
    Rambling observations over for now.
    AC

  • Move posts from one tabel to another with checkboxes in HTML DB

    I wish to replace the checked rows from one table to another with a PL/SQL statement.
    When I wish to replace one row, there is no problem. But when I wish to replace two or more I get an error ORA-00001: unique constraint (HTMLDB_ERASMUS.SYS_C0042823) violated.
    The only unique constraint in my table is the primary key ID, witch is generated with a sequence, so normally there is never twice the same value for an ID.
    Can someone help me here, please?
    Here is my code
    DECLARE     
    lv_i NUMBER :=1;
    lv_ID add_post.ID%TYPE;
    lv_auteur add_post.auteur%TYPE;
    lv_titel add_post.titel%TYPE;
    lv_community add_post.community%TYPE;
    lv_rating add_post.rating%TYPE;
    lv_description add_post.description%TYPE;
    CURSOR move_posts iS
    SELECT ID, auteur, titel, community, rating, description
    FROM add_post
    WHERE ID = HTMLDB_APPLICATION.G_F01(lv_i);
    BEGIN
    FOR lv_i IN 1..HTMLDB_APPLICATION.G_F01.count LOOP
    OPEN move_posts;
    FETCH move_posts INTO lv_ID, lv_auteur, lv_community, lv_titel, lv_rating, lv_description;
    INSERT INTO wouter_published_posts VALUES (lv_ID, lv_auteur, lv_community, lv_titel, lv_rating, lv_description);
    DELETE FROM add_post WHERE ID = HTMLDB_APPLICATION.G_F01(lv_i);
    --EXIT WHEN move_posts%NOTFOUND;
    COMMIT;
    CLOSE move_posts;
    END LOOP;
    END;

    That should not be necessary because I get the value of ID out of another table, where I generate ID with a sequence..
    So normally it should just tranfer that row from one table to another. But it doesn't !
    Knowing that I cannot create a row in the table wouter_published_posts(I can just move rows from the add_post table to the wouter_published_posts table), It should be inpossible that twice the ID appears. But yet he keeps trowing errors...
    help me, please

  • IMovie '11 - Move Events From One Hard To Another, Loses Keywords!

    Hi. I've been importing lots of video on to my iMac's hard drive, keywording the Events, and then moving the Events to an external hard drive using iMovie's Event Library.
    My problem is, once I've moved the Events, all of the keywording I did on them is lost. Is this what's supposed to happen? Am I doing something wrong?

    I have heard other people say that when they did a COPY rather than MOVE, they preserved their keywords.

  • Ical keeping both events when I move events from one google calendar to another

    Hi all!
    I use multiple google calendars and sync them with my iPad, iPhone, and MacBook Air. I like to move events from one calendar to another (for color coding purposes), and am coming across a unique issue that I hope someone has a solution to.
    When I edit an event by moving the event from one calendar to another the events show up correctly on the iPhone and iPad, but not in my iCal on MacBook Air. (Only when I make the changes on my iPhone and iPad). For example, when I switch an event originally created in my 'appointments' calendar to my 'done' calendar the event shows up appropriately on iPhone and iPad, and even in my Google calendars on the web. But, the iCal on my MacBook Air keeps both events. This only happens when I make the changes from the iPhone or iPad. If I make calendar changes on my computer, then there are no hiccups on any of the devices.
    It seems like a syncing issue with iCal, and I can't figure out how to prevent the duplications in my iCal on my computer from showing up. Quite annoying because I have to go in and delete all of the duplicated events on the computer at the end of the day.
    I have the Mavericks OS on my MBA and the software on my iPad and iPhone are updated to the latest software.
    If you have any suggestions, please let me know! Thanks!

    Petrill,
    Thank you. I was trying to do that yesterday, but it was grayed out. It seemed to work alright today.
    Thanks,
    Sheena

  • Move VM from one server to another using Local Repositories

    There is the following structure:
    ovhost-01 with first_repo
    ovhost-02 with second_repo
    Oracle VM version: 3.1.1
    Both first_repo and second_repo are Local Repositories.
    On ovhost-01 I have VM named "TestOVM" with status Stopped .
    Task:
    Move VM from ovhost-01 to ovhost-02 using "Clone or Move" section from VM Manager ( http://docs.oracle.com/cd/E27300_01/E27309/html/vmusg-vm-manage.html#vmusg-vm-move )
    Whenever I try VM moving virtual disk stays on the first_repo.
    With shared NFS-storage this feature working well.
    Question:
    Is it possible to move VM from one server to another with Local Repositories ?

    Neither ovhost-01 nor ovhost-02 have access to each other. It move or copy... the admin server that is connected to the local repository would have to have access to the target repository.

  • Are there any APIs to move funds from one project to another?

    Hi,
    Are there any Project/Budget APIs to move funds from one project to another with in the same grant or different grant in R12?
    Thanks,

    Hi
    There are API's to load or update budget line amounts, PA_PROJECT_PUB.
    There are API's to load or update agreements and allocate funds to projects, PA_AGREEMENT_PUB
    Dina

  • File move from one dir to another with SXPG_COMMAND_EXECUTE

    Hi all,
    Need some help in using UNIX COMMAND with SXPG_COMMAND_EXECUTE.
    I need to move files from one directory to another with MV command,so anybody have any idea regarding the same?
    If any sample code then that will be really gr8.
    Its urgent requirement so pls do the needful
    Thanx in advance

    Hi
    You will have to create external operating system command in SM69 to use with SXPG_COMMAND_EXECUTE. Pass the command name that you create in sm69 to this FM .
    You would need authorization objects S_LOG_COM, S_RZL_ADM to be able to successfuly use this FM.
    Regards
    Kalpana

  • IMovie 10 - how do I move an event from one library to another?

    Greetings,
    I have updated all of my projects and events from iMovie 9 to iMovie 10.0.1. They now all sit in different libraries on different external HDDs.
    How do I move an event from one library to another library in iMovie 10? How do I copy an event from one library to another library in iMovie 10?
    Thanks,
    John

    Simply drag and drop from one library to another.  See:  http://help.apple.com/imovie/mac/10.0/#mov3fa25bae7
    Geoff.

  • How do I move pictures from one library to another?

    How do I move pictures from one library to another?

    For just a few export them out of Library A via the File ➙ Export ➙ File Export menu option with Kind = Original and import them into Library B.
    However, this will not include any edits or metadata (keywords, titles, etc.) that you've added.
    To get the original image, any edits and all metadata, keywords, titles, descriptions, places, etc., you'll need the paid version of  iPhoto Library Manager.  It can copy albums or events from one library to another and keep those items I mentioned earlier with the photos.
    OT

  • How to move cursor from one textfield to another textfield byusing enterkey

    hii all,
    I have a problem in java script.
    To move cursor from one textbox to another text box ,I have take the length of the textboxes of the first column.I used onkeyDown event .
    in the function ,firest i checked the condition like
    for(i=0;i<form1.box.length;i++) //box is the name of the textboxes
    if(event.keyCode==13)
    form1.box[i+1].focus();
    return false;
    by using this the cursor is moving from first text box to secon textbox and stops.
    if i use event.returnValue=false; instead of return false ,then the cursor automatically going to the laxt textbox of the column.
    my problem is how i can focus the cursor from one textbox to another textbox one after the other till the end.
    if any one has solution please help me.
    also if we can do in another way also,please help me.
    thanx.>

    try the following code :
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <SCRIPT language="Javascript">
    function fnTest(str)     {     
              if(event.keyCode==13)          {
                   if(str == 4)     {
                        formHeader.box[0].focus();
                   else     {
                        formHeader.box[parseInt(str)+1].focus();
                   return false;
    </SCRIPT>
    <BODY>
    <FORM name="formHeader">
    <CENTER>
    <INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('0');">
    <br>
    <INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('1');">
    <br>
    <INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('2');">
    <br>
    <INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('3');">
    <br>
    <INPUT TYPE="TEXT" name="box" value="" onKeyDown="javascript:fnTest('4');">
    </CENTER>
    </FORM>
    </BODY>
    </HTML>
    ----------------------------------------------

  • Can I move applications from one user to another on the same computer?

    If I have two users on one mac, can I move applications from one user to another on the same computer?
    Thanks

    By default, apps are installed for all the users in /Applications

  • Can i move money from one account to another?

    Can i move money from one account to another?

    Basically, no; only the iTunes Store staff can do this, and then only by putting the balance from a completely unspent gift card back onto the card.
    (83942)

  • How do I move contacts from one group to another?

    I entered several contacts in address book.  How do I control which group they are assigned to at the time of entry?  The ones I added showed up in my office contacts in Outlook instead of in Hotmail/iCloud.
    Is it possible to move them from one group to another once entered?

    Do the contacts that are not in iCloud belong to an external account such as Gmail, Yahoo or an Exchange account?  Or, do they belong to On My iPhone?

Maybe you are looking for

  • Error message needs to be generated in case of change in released PO.

    Hi all, please help me how to solve this issue <b>issue1:</b> Error message needs to be generated in case of change in released PO. 1) change in incoterms,   2) payment terms,                  3) quantity                              4) rate.        

  • About CATS attachment

    Hi gurus, I am having a problem with the CATS approval workflow.When clicking on the attachment of  the workflow we are getting a short dump. Short text Program error: ASSIGN with length 0 in program "SAPLSWOT". What happened? Error in the ABAP Appli

  • Missing photos when importing from a Fuji s602zoom digital camera

    I noticed that when I import the photos from my digital camera (as above), sometimes there are some missing. No error messages displayed and the import seems to finish OK. This makes life difficult as I cannot now trust iPhoto and have to check every

  • [svn:fx-trunk] 11191: add mxmlc_ja to the mxmlc classpath so Japanese messages will be displayed in builder .

    Revision: 11191 Author:   [email protected] Date:     2009-10-27 12:51:40 -0700 (Tue, 27 Oct 2009) Log Message: add mxmlc_ja to the mxmlc classpath so Japanese messages will be displayed in builder. QE notes: loc team to make sure ja msgs appear Doc

  • Nano recognized in iTunes only when in disk mode...

    I went through all of the 'r' process to restore the iPod Nano and reinstall , etc... but still iTunes recognizes the Nano only when I put it in Disk mode ! I can see it in windows but not in iTunes if it's in normal mode. Diagnostic tool says that e