Created
February 14, 2015 12:03
-
-
Save henryroe/085cead4751d19c2a5ad to your computer and use it in GitHub Desktop.
Save mail attachments after pre-pending YYYY-MM-DD_
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
set outputPath to choose folder | |
tell application "Mail" | |
set curMessage to selection | |
set listAttachments to mail attachment of item 1 of curMessage | |
set curMessageDate to date received of item 1 of curMessage | |
set dateStr to (rich text -4 thru -1 of ("0000" & (year of curMessageDate))) & "-" & ¬ | |
(rich text -2 thru -1 of ("00" & ((month of curMessageDate) as integer))) & "-" & ¬ | |
(rich text -2 thru -1 of ("00" & (day of curMessageDate))) | |
repeat with a from 1 to length of listAttachments | |
set curAttachment to item a of listAttachments | |
set curSavePath to (outputPath as string) & (dateStr & "_" & (name of curAttachment)) | |
save curAttachment in curSavePath | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment