Applescript – Discover if the calendar occasion already exists

[ad_1]

I’m attempting to create a script that copies occasions from my work calendar to a private however simply as time blocks in order that my partner is aware of when I’ve conferences. From scouring the web for a bit I got here up with the next script which works for essentially the most half.

set SourceCalendarName to "Work"
set DestinationCalendarName to "Mirror"
set at present to present date

set numberofdays to 7
set startday to ((present date) - (1 * days))
set endday to ((present date) + (numberofdays * days))

inform software "Calendar"
    
    set sourceCalendar to calendar SourceCalendarName
    set destinationCalendar to calendar DestinationCalendarName
    
    
    -- Copy sources to vacation spot --
    repeat with sourceEvent in (get occasions of sourceCalendar whose (begin date is bigger than or equal to startday) and (begin date is lower than endday))
        
        
        inform sourceEvent
            set |allday occasion| to allday occasion
            set |begin date| to begin date
            set |finish date| to finish date
            set |recurrence| to recurrence
            set |description| to description
            set |abstract| to abstract
            set |standing| to standing
            set |abstract| to "VV Assembly"
            
        finish inform
        
        
        delete (occasions of destinationCalendar whose begin date is the same as |begin date| and finish date is the same as |finish date|)
        inform destinationCalendar
            set destEvent to (make new occasion at finish of occasions with properties abstract)
        finish inform
        
    finish repeat
finish inform

I’m attempting to not have the delete occasions half however test if there may be an occasion already and never trouble creating an occasion within the first place

delete (occasions of destinationCalendar whose begin date is the same as |begin date| and finish date is the same as |finish date|)

Any tips about tips on how to change this to an if-condition in order that the inform even will be optionally available?

Thanks

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *