Hi all,
I am new to this and I would like to know if it is possible to create a Script for counting recurring events in a specific calendar in Mac within a week, month or year.
Thanks for all your help.
Best regards,
Jose
Hi all,
I am new to this and I would like to know if it is possible to create a Script for counting recurring events in a specific calendar in Mac within a week, month or year.
Thanks for all your help.
Best regards,
Jose
Hi. Yes, it is. It may be faster to do this without a whose filter, but this is quick enough for a relatively compact number of entries.
set traversalPast to {}
set quantifiedResult to {}
set isDate to current date
set backDate to 365 --time range criteria
tell application "Calendar" to tell calendar "home" to repeat with iterator in (get events whose (start date < isDate) and (start date > ((isDate - backDate * days))))
if traversalPast does not contain iterator's summary then set quantifiedResult's end to iterator's summary & space & (count (events whose summary is iterator's summary and (start date < isDate) and (start date > ((isDate - backDate * days)))))
set traversalPast's end to iterator's summary
end repeat
quantifiedResult
Hi JoMiSan,
Did you want the number of times a certain recurrence event happens (day, month, or year) or the total number?
Edited: I can’t think of any reason to get the total number of recurrence events in a period other than a day maybe.
gl,
kel
I will make an example…
I am teaching to different people, so I have a calendar named “Teach” and I make an input in that calendar for every class I do, and the event name is the name of the person I am teaching… so, I would like to be able to get from calendar for example… how may classes did I give to XXX in January?.. or in 2013?..
Right now, I just type the person name in the calendar search and I get all the classes, but I have to be counting by month or by year.
Is there any way to make this automatic?.
Thanks all.
Best regards,
Jose
Hello, again. I also have events that recur but change by month, such as how many class activities I attend. My sample code enumerates all repeat events during a timeframe you define (backDate). Change the calendar name from “home” to “teach,” and adjust the number of days that you want to poll. If you want a specific student returned, change the first line to:
tell application "Calendar" to tell calendar "home" to repeat with iterator in (get events whose (start date < isDate) and (start date > (isDate - backDate * days)) and summary contains "student")
:)
Thanks !!!