-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,31 @@ | ||
# alfred-mail-sorter | ||
Moves currently selected message in Mail.app to a folder selected via Alfred interface | ||
Moves currently selected message in Mail.app to a folder selected via Alfred interface. | ||
|
||
## Usage | ||
With a selected message in Mail: | ||
|
||
1. Press `⌃M` (default shortcut) | ||
2. Typing `sort`command into Alfred | ||
3. Type the name of the folder (or part of it) until you see the desired folder selected | ||
4. Hit return/enter | ||
|
||
## 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. | ||
|
||
# Known Issues | ||
|
||
## Doesn't work with folders named the same accross different accounts | ||
|
||
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). | ||
|
||
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". | ||
|
||
# Credits | ||
- Icon from the Noun Project, under the Creative Commons license. | ||
https://thenounproject.com/icon/move-folder-545831/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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) | ||
set currentMailbox to mailbox of theMessage | ||
set theAccount to the account of currentMailbox | ||
end try | ||
|
||
set allAccountMailboxes to every mailbox of theAccount | ||
|
||
repeat with eachMailbox in allAccountMailboxes | ||
|
||
set thisReccord to {uid:(name of eachMailbox) & "-" & (name of theAccount), title:(name of eachMailbox), subtitle:(name of theAccount), arg:[(name of eachMailbox), (name of theAccount)], valid:true, match:(name of eachMailbox)} | ||
set the end of mailboxList to thisReccord | ||
|
||
end repeat | ||
|
||
set |items| to {|items|:mailboxList} | ||
end tell | ||
|
||
tell application "JSON Helper" | ||
set mailboxList to make JSON from ¬ | ||
|items| with pretty printing | ||
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
on run argv | ||
set theMailbox to item 1 of argv | ||
activate application "Mail" | ||
tell application "System Events" | ||
tell process "Mail" | ||
click menu item theMailbox of menu 1 of menu item 18 of menu 1 of menu bar item 7 of menu bar 1 | ||
end tell | ||
end tell | ||
end run |