Create Calendar Appointment from PDF

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Create Calendar Appointment from PDF Thu Jun 10, 2021 11:43 am • by SJamG
Hi everyone!

I have just upgraded to v5 and loving getting back into Hazel and automating my life! One thing I am itching to know how to do is to create a calendar appointment (using Apple Calendar app or Fantastical) from a date received in a letter.

Background: I am currently receiving lots of letters for appointments which are having to be moved/reschduled due to the pandemic and every time the letter arrives, I scan with my iPhone and it files it in the correct folder - all good there. As part of my rules, I also get the appointment date and use that for the filename.

What would be next level for me would be to automatically create a calendar appointment from the date and time in the letter - I have searched a few forums and not scared of a little AppleScript, but wondered if anyone had any ideas or pointers for me to achieve this?

Thank you!
SJamG
 
Posts: 2
Joined: Tue Oct 08, 2019 2:05 pm

Re: Create Calendar Appointment from PDF Fri Jun 11, 2021 10:40 am • by Mr_Noodle
You might be better off checking an AppleScript forum. You would need Hazel to pass in the date so if you have that as a custom attribute, you can set that as one of the arguments sent in. If you find a script that serves your needs, you can post it here and I can try and give some tips on integrating it into Hazel.
Mr_Noodle
Site Admin
 
Posts: 9781
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Create Calendar Appointment from PDF Fri Jun 11, 2021 1:48 pm • by SJamG
Thanks for replying...after some googling, I started with the script below, but not sure how to format the date or pass it from Hazel:

Code: Select all
set calendarName to "SJamG"
set theSummary to "Appointment"
set theDescrption to "xyz check-up"
set theLocation to "Medical Centre"
set startDate to inputAttributes
set endDate to inputAttributes

set startDate to date startDate
set endDate to date endDate

tell application "Calendar"
   tell (first calendar whose name is calendarName)
      make new event at end of events with properties {summary:theSummary, start date:startDate, end date:endDate, description:theDescrption, location:theLocation}
   end tell
end tell


Really appreciate any tips/guidance :)
SJamG
 
Posts: 2
Joined: Tue Oct 08, 2019 2:05 pm

Re: Create Calendar Appointment from PDF Mon Jun 14, 2021 10:42 am • by Mr_Noodle
inputAttributes is a list so you need to set the startDate and endDate to the item in the list. Check out this article on how to refer to items in a list: https://developer.apple.com/library/arc ... Items.html

You shouldn't need to format the dates since the are already dates. Formats only come into play when converting from/to a string.
Mr_Noodle
Site Admin
 
Posts: 9781
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion