I’m reading Deep Work by Cal Newton, which is inspiring some thoughts on how to reduce my attention to work at certain times of the day.
In particular, I’d love to setup a mail rule - either via Apple Mail Rules, Mail Act On, or Gmail rules, to move all messages received at certain times of the day to a different folder which I named “@later” similar to Sanebox.
I don’t see a straightforward way to setup this type of rule, so I’m wondering if there might be a script or plug in I could use to accomplish this desired outcome.
Thanks for any suggestions!
You could do this through Keyboard Maestro. Just set up a macro to trigger at a specific time and run an applescript that moves all mail to a folder .
something like this:
tell application "Mail"
set all_messages to (messages of mailbox "INBOX" of account "[account name]")
repeat with theMessage in all_messages
tell application "Mail"
move theMessage to mailbox "@later" of account "[account name]"
This should do it.
Thanks so much!
This is exactly what I was looking for. I had hoped that KM could do this with the proper AppleScript.
Now, my question is… Can KM perform this task every minute until the clock reaches a certain time of day?
Neither Apple Mail’s built in rules predicates nor Mail Suite’s (Mail Act On) can get more granular on time than Date Sent or Date Received. I think @JKoopmans suggestion is the way to go.
I’m not well versed in AppleScript.
Do I need to set the variable “theMessage” in the script you sent?
Also, is there a way to have the script repeat at a certain interval until the next morning?
I know I’m asking a lot!
You do not have to set theMessage, that’s a given.
I’ll look into the scheduling tomorrow
I haven’t been able to get the script to work for me. I’ll keep trying.
If you have it in script editor, does it compile ok?
Also: the inbox name is key, not all providers name them the same. so make sure you point to the inbox. (you can put an entry in the script to count all unread items f.e. and have that pop up as a message to trest wether it is the right mailbox)
Thanks, @JKoopmans! I ran this in the script editor and found that I needed to capital the ‘L’ in “@Later” to match the name of the destination folder.
So, the script is working now!
I’d still love to figure out how to repeat the script every minute or so until a certain time, if you have any insight into how to do that in KM.
What you want is the “Periodically while logged in” Keyboard Maestro trigger. Here’s a screenshot.
You cn lso have Lingon execute the script.
This is exactly what I’m looking for!
Thanks so much, @TheWart!
Nice! I’ll check this out, too!