Following up on my thread Mavericks Lion Calendar - exporting calendars as .ics files I was wondering if anyone could take a look at the Yosemite Calendar and help with fixing a script that has been very useful to me over the past years.
The functionality is actually very simple - the script backs up each calendar found within the Calendar app and saves it as an .ics file in a file directory:
Here's the error message that comes up:
And here are the reply messages from the 'Script Editor' when the script is run:
Assuming that's an easy fix again. Thanks a lot for looking into it!
The functionality is actually very simple - the script backs up each calendar found within the Calendar app and saves it as an .ics file in a file directory:
Code:
-- IMPORTANT: BEFORE RUNNING THIS SCRIPT, OPEN THE CALENDAR AND SELECT CALENDAR 'BIRTHDAYS'
-- Basic settings
set timeStamp to do shell script "date \"+%Y%m%d\""
set backup_folder to "/Users/ros/Backup/Calendar/"
do shell script "mkdir -p " & quoted form of backup_folder & quoted form of timeStamp
set savePath to backup_folder & timeStamp
-- Begin script
tell application "Calendar"
launch
activate
delay 2
set calNames to name of every calendar
end tell
tell application "System Events"
tell process "Calendar"
set frontmost to true
-- Left-hand menu of Calendar, containing named calendars
set myOutline to outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar"
set allRows to rows of myOutline
-- List of named calendars
set calNameVals to get value of static text of UI element 1 of every row of myOutline
-- For all named calendars, check whether it's the same name as one of calNames, if so export that calendar
set countLoop to 0
repeat with i from 2 to (count calNameVals)
set countLoop to countLoop + 1
set calName to item 1 of item i of calNameVals
repeat with myName in calNames
if (myName as string = calName as string) then
tell row i of myOutline
select
delay 1
end tell
click menu item "Export
" of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
delay 1
if countLoop = 1 then
keystroke "g" using {command down, shift down}
delay 1
keystroke savePath
delay 1
click button "Go" of sheet 1 of sheet 1 of window 1
end if
click button "Export" of sheet 1 of window 1
-- Change the delay time if your computer is running to slow or too fast
delay 15
end if
end repeat
end repeat
end tell
end tell
Here's the error message that comes up:
And here are the reply messages from the 'Script Editor' when the script is run:
Code:
tell current application
do shell script "date \"+%Y%m%d\""
--> "20141108"
do shell script "mkdir -p '/Users/ros/Backup/Calendar/''20141108'"
--> ""
end tell
tell application "Calendar"
launch
activate
get name of every calendar
--> {"Entertainment", "Transportation", "Relationship", "Sexuality", "Education", "Food", "Socialising", "Household", "Employment", "Errands", "Health", "Sports", "Rest", "ToDoTo", "Holidays", "Hygiene", "Location", "Birthdays"}
end tell
tell application "System Events"
set frontmost of process "Calendar" to true
get outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of process "Calendar"
--> outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar"
get every row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar"
--> {row 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 2 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 3 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 4 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 6 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 7 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 8 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 9 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 10 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 11 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 12 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 13 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 14 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 15 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 16 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 17 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 18 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 19 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar", row 20 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar"}
get value of static text of UI element 1 of every row of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "Calendar" of application process "Calendar"
--> {{"Cloud Calendar"}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"Other"}, {}}
Result:
error "Cant get item 1 of {}." number -1728 from item 1 of {}
Assuming that's an easy fix again. Thanks a lot for looking into it!