.
.
I find myself using 1 or 2 Email folders 90% of the time. And with the amount of email I get I need a fast way of moving read emails into folders for saving. Here is an applescript action to move the selected messages from your inbox to 1 or 2 folders that you setup.
To use this script I use the program Quicksilver. If you don’t have Quicksilver installed I highly recommend using it. You can read why I think Every Mac user should install Quicksilver for more info.
- Lets start by figuring out which folders you want to put in your script. For this tutorial we are going to use 2008 Archive & 2009 Archive Folders.
- Open up Script Editor (Applications/Applescript/Script Editor)
- Create a New Script and put in this code
tell application "System Events"
activate
set myAnswer1 to the button returned of (display dialog "Pick a Location" buttons {"2008 Archive", "2009 Archive", "Cancel"} default button 1)
end tell
if myAnswer1 is "2008 Archive" then tell application "Mail"
set s to selection
repeat with eachMessage in s
move eachMessage to mailbox "2008 Archive"
end repeat
end tell
if myAnswer1 is "2009 Archive" then tell application "Mail"
set s to selection
repeat with eachMessage in s
move eachMessage to mailbox "2009 Archive"
end repeat
end tell
if myAnswer1 is "Cancel" then tell application "Mail"
end tell
tell application "Mail"
activate
end tell
- To change this script for your mailboxes you need to change the names in Bold. Note if you have folders in folders you need to put both in the location (i.e. “Main Folder Name/2nd Folder”)
- Click Compile the script and it should look something like this:

- Save your script in a location you’ll find later
- Now you need to Setup a Trigger which is a Keyboard shortcut that will run your Mail Move Script from Quicksilver. So Click on the Quicksilver icon in your menu bar or in the dock and click Triggers.

- Then click the “+” sign at the bottom to create a new “Hot Key” find your Mail Move Script in the Item box and put “Run” in the Action box as shown:

- Once your shortcut has been created it will show up in your list of Triggers

- If you would like to change the keyboard shortcut simply click the
at the bottom of the window and you can change the options of the trigger.

- Now your all setup to use the script simply select the messages you want to move and activate the script using your shortcut key. You will see this box come up asking you where to move the selected messages

Notice the default button is the first choice, you can change this in the script editor by changing the default button to 2 or 3. Once this box is open you can also tab through the choices and hit [space] to select the mailbox.







I’m SOOO happy I found this page! I was wanting to buy Mail Act-On after the trial expired, but just couldn’t bring myself to pay $50 for two copies (one for me and one for my wife). Now, with just a little applescript and quicksilver, I have a complete recipe for mail sorting liberation!
Thanks so much!
The code below solves addresses the following issues I was having:
1) by using a list instead of a dialog with buttons, you
…..a) are not limited to only 3 options like the above method (3 buttons max)
…..b) get the cancel button and logic for free (i.e., you don’t have to code it)
…..c) get the ability to navigate up/down the list with arrows (won’t work if you turn off default)
3) I needed to specify the account for my mailboxes
Note: To keep the same structure, I left this as a bunch of individual if–then statements. It’s probably more efficient to use if–then–else. But for just a few options, it’s not a big deal.
–PRETTY VERSION:
– http://screencast.com/t/9B9nL9j4Gk
–TEXT VERSION:
tell application “System Events”
activate
set myMailAccounts to {“Saved”, “Action”, “Later”}
choose from list myMailAccounts with title “Move Message(s)” with prompt “Choose Mailbox?” default items {“Saved”}
set selectedMailBox to result as string
end tell
if selectedMailBox is “Saved” then tell application “Mail”
set s to selection
repeat with eachMessage in s
move eachMessage to mailbox “Saved” of account “MACMAIL”
end repeat
end tell
if selectedMailBox is “Action” then tell application “Mail”
set s to selection
repeat with eachMessage in s
move eachMessage to mailbox “Action” of account “MACMAIL”
end repeat
end tell
if selectedMailBox is “Later” then tell application “Mail”
set s to selection
repeat with eachMessage in s
move eachMessage to mailbox “Later” of account “MACMAIL”
end repeat
end tell
tell application “Mail”
activate
end tell
Nice, but somewhat lame. Need to have a list come up so you can select or better yet type part of a folder name so the message can be moved. Less use of the mouse the better. Entourage has this support built in and I miss it.
The code created above by drowelf is a great solution if you want a list with more then two mailbox’s to come up.
The list looks like this:
And if you want more options I suggest using Mail Act-On ($24.95) it adds a lot of features.
The idea behind using a simple applescript is it’s easy enough for users to implement and it’s free…
Is there a way to trigger the script automaticaly when the messages are read?
For something like that I would use Mail Act-On ($24.95) I am not sure if it has that functionality but it may.
mail act on doesn’t seem to be able to automatically move unread messages. anyone know of away to make a script like this do that??
Simple, yet very effective for me, is the option-command-t shortcut which moves a message to the last folder you moved a message to… and mail seems to remember that folder even after quitting and starting the app.
thanks!
I’ve used drowelf’s code and because I have sub-folders, used “Folder”/”Subfoldername” as Mailbox name. That works for me. The names in the MyMailAccounts {..} can be different, but the Mailbox name must correspond with the name (and location) of the original folder.
I have a problem that it works System wide, despite putting the Scope in Quicksilver for the keyboard shortcut on Mail.app… Is this a Quicksilver problem? Or something else?
Even easier than all this is to just use System Preferences → Keyboard → Keyboard Shortcuts → Application Shortcuts → Add. You can type the name of the mailbox (assuming it’s unique) and give it a shortcut. This works because you can use the menu to move an email to a mailbox (Message → Move To…).
I am not familiar enough with quicksilver to know about limiting it to just mail.app. But it may be because you are making a trigger that runs an applescript, then the applescript interacts with mail.app so you can’t really limit the trigger just to use mail.
The shortcut I have selected only gets used for the “mail move” so if I press it in another app it activates the applescript and will move whatever message was left selected in Mail.app
This is true you can make shortcuts through System Preferences however you will then need to remember the shortcut for each mailbox. My applescript or the even better solution posted by drowelf you only need to remember one shortcut and can add mailbox’s as you like to the applescript.
Very nice what you did there!
But I would like to know how you can copy single mail to a folder outside the mail program by using Mail Act-on?
Could somebody help me, please?
Andreas
If you are looking for MailActOn Support head over to there site: http://www.indev.ca/MailActOn.html
This post is for people who would rather not use/pay to just be able to move messages around.