Task:
I want to create an AppleScript that will let me quickly and easily create a set of review dates for my daily studies. I’m brand-new to AppleScript, so please bear with me. I’ve tried to write out the problem in as much detail as possible to make it clear what I’m trying to do here. Basically I enter the initial lesson name as an event (at such a time and such a date), then I enter 5 individual review date events (at the same time of day) for that lesson thereafter. The way I currently do it is like this:
- Create a new entry in iCal, with the Lesson Number as the Event Name, and the time
- Create followup entries for study reviews, 5 total - 1 day after the initial event, 3 days after, 7 days after, 37 days after, and 402 days after
- If a study date ends up on a Sunday, it gets moved to the next day (Monday) - I only study 6 days a week (Mon-Sat), then take Sunday off
So for each initial study period, I have 5 review sessions afterward spaced 1 day, 2 days, 4 days, a month, and a year later. It’s a type of incremental-repetitive review that I’ve found works really well for me. Anyway, I want to automate the entry of this, so that I only have to input the original Lesson Name, the Date of the original lesson, the Start Time of the original lesson (duration is always 15 minutes), and the specific Calendar I want to apply the events to. This way I can just save the AppleScript as an application and run it whenever I have a new lesson that I need to have reviews for. So I end up with a total of six (6) entries - the original study date, and then 5 review dates after that, spaced out.
Input Variables:
I want a GUI dialog box of the following:
Lesson Date: [select either “Today” or “Custom”; if Custom, then manually input the date]
Lesson Name: [input box]
Start Time: [manually input start time]
Select Calendar: [choose which existing calendar to apply the events to]
Then I want a “Save” button that applies the workflow below and exits the AppleScript.
Program Workflow:
- Enter variables in dialog box GUI
- Click “Save”
- Create Entry for the Original Lesson:
Event Date = Lesson Date Variable
Event Name = Lesson Name Variable
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Create Entry for Review #1:
Event Date = Lesson Date Variable + 1 Day
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #1"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Create Entry for Review #2:
Event Date = Lesson Date Variable + 3 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #2"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Create Entry for Review #3:
Event Date = Lesson Date Variable + 7 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #3"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Create Entry for Review #4:
Event Date = Lesson Date Variable + 37 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #4"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Create Entry for Review #5:
Event Date = Lesson Date Variable + 402 Days
If New Event Date = Sunday, then change to the next day (Monday)
Event Name = Lesson Name Variable = " - Review #5"
Start Time = Start Time Variable
End Time = Start Time Variable + 15 minutes
Calendar to apply to = Selected Calendar Variable
- Exit AppleScript
Summary:
So, I think the idea is pretty easy, but I’m not at all familiar with AppleScript and I’m really struggling to make it work. I’d really appreciate it if someone could walk me through coding this puppy. Thanks in advance!