Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 4, 2012, 05:03 AM   #1
bibyfok
macrumors member
 
Join Date: Jun 2012
AppleScript modification: Check if event already exist

Hi all,

I found an AppleScript on the web to duplicate calendar events but I need some help in order to adapt it:

I run it every hours but the script keeps duplicating already duplicated events.

Is there a way to check if any events already exist before duplicating it?
I'm a total newbie on scripting so any help would be extremely appreciated…

Thanks!

Code:
--iCal Event Duplicator.scpt
--Writen by Mike Cramer
--January 10, 2011 ~ 4pm CST
--
--Assume GPL style license.

tell application "iCal"
  
  set TheCalendars to name of calendars
  
  set theSourceCalendar to ""
  set theDestinationCalendar to ""
  
  choose from list TheCalendars with title "Please select a source calendar" without empty selection allowed
  set theSourceCalendar to result as string
  
  if theSourceCalendar is "" then
    --do nothing
  else
    
    set theOtherCals to {}
    repeat with anItem in TheCalendars
      if (anItem as string) is not (theSourceCalendar as string) then set theOtherCals to theOtherCals & anItem
    end repeat
    
    choose from list theOtherCals with title "Please select a destination calendar" without empty selection allowed
    set theDestinationCalendar to result as string
    
    
    if theDestinationCalendar is "" then
      --do nothing
    else
      
      display dialog "Copy calendar events from " & theSourceCalendar & " to " & theDestinationCalendar & "?" buttons {"OK", "Cancel"} default button 2
      if the button returned of the result is "OK" then
        set TheEvents to events of calendar theSourceCalendar
        
        repeat with anEvent in TheEvents
          
          tell anEvent
            set theProperties to properties
            
            set THEdescription to description
            if THEdescription = missing value then set THEdescription to ""
            set thestartdate to start date
            if thestartdate = missing value then set thestartdate to ""
            set THEenddate to end date
            if THEenddate = missing value then set THEenddate to ""
            set THEalldayevent to allday event
            if THEalldayevent = missing value then set THEalldayevent to ""
            set THErecurrence to recurrence
            if THErecurrence = missing value then set THErecurrence to ""
            set THEexcludeddates to excluded dates
            --      if THEexcludeddates = missing value then set THEexcludeddates to ""
            set THEstatus to status
            if THEstatus = missing value then set THEstatus to ""
            set THEsummary to summary
            if THEsummary = missing value then set THEsummary to ""
            set THElocation to location
            if THElocation = missing value then set THElocation to ""
            set THEurl to url
            if THEurl = missing value then set THEurl to ""
            
          end tell
          
          tell calendar theDestinationCalendar
            make new event at end with properties {description:THEdescription, start date:thestartdate, end date:THEenddate, allday event:THEalldayevent, summary:THEsummary, location:THElocation, url:THEurl}
          end tell
        end repeat
      else
        --do nothing
      end if
    end if
  end if
end tell
bibyfok is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Tags
applescript, duplication, events, ical, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript how to check radio button redwgaontoy Mac Programming 1 Jun 18, 2013 09:35 AM
[AppleScript] Check what application is running in the foreground Amad3U5 Mac Programming 2 Jan 27, 2013 02:16 PM
Check off Finished Event in Calendar boba7523 OS X 10.8 Mountain Lion 3 Jan 18, 2013 03:39 PM
Anyone know of an Applescript to check if an app is NOT running? amityweb Mac Programming 1 Oct 18, 2012 03:42 PM
AppleScript-driven Calendar repeating event creation wrldwzrd89 Mac Programming 2 Oct 16, 2012 08:26 PM

Forum Jump

All times are GMT -5. The time now is 10:55 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC