0.2 C
New York
Wednesday, December 25, 2024

Applescript – Discover if the calendar occasion already exists


I’m making an attempt 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 the moment 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 larger than or equal to startday) and (begin date is lower than endday))
        
        
        inform sourceEvent
            set |allday occasion| to allday occasion
            set |begin date| to start out 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 )
        finish inform
        
    finish repeat
finish inform

I’m making an attempt to not have the delete occasions half however test if there’s 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 on how you can change this to an if-condition in order that the inform even may be non-compulsory?

Thanks

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles