I use Mail.app under OS X, so searching is easy and quick. I can use smart mailboxes as needed for subject-based organization, so I wanted to move away from my existing subject-based organization scheme (a folder for each person, job, client, etc.). But since I have about 7 years of email on my machine, I still wanted to do better than one big mailbox. Grouping the messages based on the date sent seemed to give me manageable chunks, but I didn't want to have to do that manually. So, I came up with this script:
on archiveByDate(parentMailboxName)
tell application "Mail"
set archiveMessages to the selection
repeat with currentMessage in archiveMessages
set receivedon to (date received of currentMessage)
set archiveYear to (year of receivedon as string)
if ((month of receivedon as number)
This automatically maintains a folder hierarchy like:
- parentMailboxName
- 2006
- 01
- 02
- ...
I use that script as a library, and have another script which I run via a MailActOn action to file selected messages. The reason for having a separate script is so I can separate personal messages from work messages in the archive. For example,
set scriptDirectory to ((path to
scripts folder as string) & "Mail Scripts")
set scriptPath to (scriptDirectory & ":MailArchiveByDate.scpt")
set theScript to (load script alias scriptPath)
tell theScript to archiveByDate("Personal")
saves my personal messages to a folder called "Personal", while
set scriptDirectory to ((path to
scripts folder as string) & "Mail Scripts")
set scriptPath to (scriptDirectory & ":MailArchiveByDate.scpt")
set theScript to (load script alias scriptPath)
tell theScript to archiveByDate("Work")
saves work messages to a separate set of folders.
5 comments:
hello. does this still work in mail.app 3.4? i tried but it just blinked and didnt do anything...
I haven't updated to Mail 3.4 yet (I'm on 3.3). Where did you get your copy?
When I debug the script, I usually run it through Script Editor (instead of the MailActOn trigger) and watch the log tab while it runs. You might want to give that a try, since I don't have access to 3.4, yet.
i just update through software update, and choosing 'about mail' shows Version 3.4 (928/928.1). ill try the debug thing.
actually, i just tried that, and if i run it in script editor, nothing happens at all, neiter for archivemessages.scpt nor for mailarchivebydate.scpt - that is i dont get any message in the event log tab. maybe i dont get it, but IF i create a folder on the top hierarchy (on my mac) called Archive, i dont have do change the scripts at all, right? and the subfolders (by date and month) should be created automatically, no? thanks for any help!
Make sure you have at least one message selected, the script only works on selected messages.
It will probably be faster to debug this if you email me directly (see upper right corner of the page).
Post a Comment