Setting a reminder when a file is added to my "Process" folder

Hello Automator community!

I’m looking for a way to create a reminder when I add a file to a specific folder (Process) on my Mac. If it’s important to know, this folder lives in iCloud Drive. Originally I thought this would be a job for Hazel but I do not see a way for Hazel to create a Reminder. My next move was to use Automator/Hazel but Automator only allows you to choose a specific date for the notification on the due date. Here is the general workflow I’m looking for:

  • File gets added to Process folder
  • A task is generated in my Personal reminder list in Reminders.app
  • The task is set to remind me on the following Sunday night at 8:00p
2 Likes

There are two options I think.

  1. The first is hazel and an automator script (you can choose “create reminder note” there).

  2. The other option should be an apple script. I use a script to add a calendar date to fantastical which is very useful – I use this script for tickets I get. It is not what you are looking for, but maybe it gives you some ideas where to look further (maybe the noodlesoft forum, or someone here knows how to change the script?)
    Anyways, that’s the script:

    tell application "Finder"
    set myName1 to inputAttributes
    set myURL to URL of theFile
    tell application "Fantastical 2"
    parse sentence myName1 notes myURL with add immediately
    end tell
    end tell
    

As input Attribute it takes the filename, where the date is included, which fantastical automatically parses to the matching date in my calendar.
So maybe you, or someone can figure out how to set this up in reminders?

1 Like

Try not to nest application tell blocks like this. It’s potentially setting up terminology conflicts, creates a false inheritance chain between application objects that aren’t related, makes code less readable, and is generally accepted to be poor form.

The script ought to look more like this:

tell application "Finder"
    set myName1 to inputAttributes
    set myURL to URL of theFile
end tell

tell application "Fantastical 2"
        parse sentence myName1 notes myURL with add immediately
end tell
2 Likes

Thank You ! I changed it accordingly and learned something! :slight_smile:

2 Likes

Can this be done without Fantastical? I’m using native Reminders.app along with Calendar.app and do not have a need at this point to switch.

Yes apple script works with the reminders.app.
Maybe this helps:
https://www.louismrose.com/2017/02/18/automating-reminders-with-applescript/

Very helpful! Hopefully last request for this one:

How do I get the reminder date/time to be the following Sunday at 8pm?

Did you see my reply to your other post here?

2 Likes

No, sorry it didn’t ping me it was replied to…reading now.

Got it. Now that I’ve seen there might be an easier way (your original script but for Reminders), I wondering if it would be easier to incorporate a reminder on Sunday to the simple code.

That said, would it be easier to incorporate it to the code on this page? https://www.louismrose.com/2017/02/18/automating-reminders-with-applescript/

Fixed it! I can’t thank y’all enough for the help!!! :raised_hands:t2:

tell application "Reminders"

set currentWkday to weekday of (current date) as string
if currentWkday = "Monday" then
	set currentDay to (current date) - (time of (current date)) + (6 * days)
else if currentWkday = "Tuesday" then
	set currentDay to (current date) - (time of (current date)) + (5 * days)
else if currentWkday = "Wednesday" then
	set currentDay to (current date) - (time of (current date)) + (4 * days)
else if currentWkday = "Thursday" then
	set currentDay to (current date) - (time of (current date)) + (3 * days)
else if currentWkday = "Friday" then
	set currentDay to (current date) - (time of (current date)) + (2 * days)
else if currentWkday = "Saturday" then
	set currentDay to (current date) - (time of (current date)) + (1 * days)
else if currentWkday = "Sunday" then
	set currentDay to (current date) - (time of (current date)) + (0 * days)
end if
set theDate to currentDay + (20 * hours)
set myList to list "Work"

tell myList
	# Create the reminder
	set newReminder to make new reminder
	set name of newReminder to "You have a file to process"
	set remind me date of newReminder to theDate
end tell

end tell

1 Like

This script can be simplified somewhat to this:

set now to the (current date) -- date and time at present
set midnight to now - (now's time) -- most recent midnight, i.e. today's
set evening to midnight + 20 * hours -- 8pm today
set today to now's weekday -- today's day of the week
set sundayEvening to evening + (8 - today) mod 7 * days -- Sunday at 8pm

tell application "Reminders"
	set myList to list "Work"
	tell myList to set newReminder to make new reminder
	set name of newReminder to "You have a file to process"
	set remind me date of newReminder to sundayEvening
end tell

Weird but doesn’t seem to be working. No task added when I run it through ScriptEditor.

You’ll need to give me more information than “it isn’t working”. What output gets fed to the Replies pane at the bottom (if you normally the Result pane selected by default, you’ll need to switch to Replies before running the script again).

For an additional clue during debugging, you can insert the line log sundayEvening just after its declaration and before the tell block.

Here’s my Replies output, following a successful run of the script today (Wednesday 21 August 2019):

tell current application
	current date
		--> date "Wednesday, 21 August 2019 at 21h53m13"
	(*date Sunday, 25 August 2019 at 20h00m00*)
end tell
tell application "Reminders"
	get list "Stuff"
		--> list id "C4A00E8C-45B8-46B9-9775-C622D379FD18"
	make new reminder
		--> reminder id "x-apple-reminder://D9A569E2-582B-45C3-A7CD-0022AF91FE73"
	set name of reminder id "x-apple-reminder://D9A569E2-582B-45C3-A7CD-0022AF91FE73" to "You have a file to process"
	set remind me date of reminder id "x-apple-reminder://D9A569E2-582B-45C3-A7CD-0022AF91FE73" to date "Sunday, 25 August 2019 at 20h00m00"
end tell