Last active
August 29, 2015 13:56
-
-
Save nriley/9293373 to your computer and use it in GitHub Desktop.
Save to Date
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
on replace_chars(this_text, search_string, replacement_string) | |
set AppleScript's text item delimiters to the search_string | |
set the item_list to every text item of this_text | |
set AppleScript's text item delimiters to the replacement_string | |
set this_text to the item_list as string | |
set AppleScript's text item delimiters to "" | |
return this_text | |
end replace_chars | |
on dlog(foo) | |
do shell script "logger -s \"" & replace_chars(foo, "\"", "\\\"") & "\"" | |
end dlog | |
on run | |
local theMessages, savedMailboxName | |
tell application "Mail" | |
if front window is not front message viewer's window then | |
tell application "System Events" to tell application process "Mail" to key code 123 using control down | |
return | |
end if | |
set theMessages to selected messages of front message viewer | |
-- my dlog(("got " & (count theMessages) as string) & " message(s)") | |
tell application "Mail" | |
try | |
repeat with eachMessage in theMessages | |
-- my dlog(subject of eachMessage) | |
get eachMessage's mailbox | |
if the result's name is "sabi.net" or the result's container's name is "+" then | |
set savedMailboxName to "Saved (sabi.net)" | |
else | |
set savedMailboxName to "Saved" | |
end if | |
get eachMessage's mailbox's account's mailbox "!"'s mailbox savedMailboxName | |
move eachMessage to the result | |
end repeat | |
on error ee | |
my dlog("error: " & (ee as string)) | |
end try | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment