Created
February 23, 2016 14:10
-
-
Save shibaku/8401052f29ac449453aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
tell application "Mail" | |
set selectedMessages to selection | |
set destinationFolder to choose folder with prompt "Pick a Destination" | |
repeat with currentMessage in selectedMessages | |
repeat 1 times | |
set msgSenderFull to extract name from sender of currentMessage | |
set msgSender to word 2 of msgSenderFull | |
set msgAttachments to mail attachments of currentMessage | |
if (msgAttachments is equal to {}) then | |
exit repeat | |
end if | |
tell application "Finder" | |
if not (exists folder msgSender of destinationFolder) then | |
set senderFolder to (make new folder at destinationFolder with properties {name:msgSender}) | |
else | |
set senderFolder to (folder msgSender of destinationFolder) | |
end if | |
end tell | |
repeat with currentAttachment in msgAttachments | |
if (downloaded of currentAttachment is true) then | |
set currentAttachmentPath to (senderFolder as string) & (name of currentAttachment) | |
save currentAttachment in currentAttachmentPath | |
end if | |
end repeat | |
end repeat | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment