Skip to content

Commit

Permalink
v 0.0.2 with AppleScript retooled
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebritto committed Sep 25, 2023
1 parent 92ceb3a commit 2ef0379
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
Binary file modified Mail Message Sorter.alfredworkflow
Binary file not shown.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ With a selected message in Mail:

## How does it work
1. Uses AppleScript to enumerate folder names for the selected account and feed a *Script Filter* on the Alfred Workflow;
2. Selecting the desired folder will feed the next action with the name of such folder;
3. A seccond AppleScript will use the name of the folder to select the corresponding "Move to…" item in menubar.
2. Selecting the desired folder will feed the next action with the name of such folder and the name of its account;
3. A seccond AppleScript will use this info to issue a move command to each of the selected messages.

# Known Issues

## Doesn't work with folders named the same accross different accounts
## Does not work with Gmail accounts
For some reason I suspect is related do the way Mail handles Gmail's proprietary protocol, I guess the move command is not properly held.

Will not work for folders in different accounts that share the same name (there's an AppleScript workaround for that move command, but it does not work fine with Gmail accounts, this is why I've preffered this method).
Previously, I used a move commant based on a System Events requisition to click on the corresponding "Move to…" command. Gmail worked fine this way. That, however, needed folders to have different names on each account and, also, will require retooling yearly (every time macOS updates), since the position of the menus could change. Different languages were also a con…

To work around this limitation, I suggest adding a capital letter to the end of the name of the chosen folder, identifying the account. As in:
- Gmail "Later" will be renamed to "Later G"
- Work "Later" will be renamed to "Later W"

This way one can easily surface the correct folder for each account by typing "Later".
Current approach does work properly with Exchange and iCloud accounts. Others may work as well.

# Credits
- Icon from the Noun Project, under the Creative Commons license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set accountList to {}
set mailboxList to {}

tell application "Mail"


try
if selection is {} then error
set theMessage to the first item of (selection as list)
Expand All @@ -25,6 +27,6 @@ tell application "Mail"
end tell

tell application "JSON Helper"
set mailboxList to make JSON from ¬
set mailboxList to make JSON from Â
|items| with pretty printing
end tell
end tell
15 changes: 15 additions & 0 deletions move command.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on run argv
tell application "Mail"
try
set mailboxName to item 1 of argv
set theAccount to item 2 of argv
if selection is {} then error
set messageList to (selection as list)
repeat with theMessage in messageList
-- set theMessage to the first item of (selection as list)
set theMailbox to mailbox mailboxName of account theAccount
set mailbox of theMessage to theMailbox
end repeat
end try
end tell
end run
9 changes: 0 additions & 9 deletions move command.scpt

This file was deleted.

0 comments on commit 2ef0379

Please sign in to comment.