Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Move messages to a target folder via keyboard shortcut Apps
Snow Leopard only hintThis is how to assign a single keyboard shortcut to move a selected message in Mail.app into a designated folder -- e.g., a Gmail-style archive folder.

You can do this with Mail Act-On, but that costs money. You should be able to do this simply with OS X's assignable keyboard shortcuts, but that fails: OS X doesn't let you describe a command in a way that distinguishes between moving and copying a message. This method uses a keyboard shortcut plus a Service plus AppleScript. Ugly but it works.

There are two steps, creating a Service that will move the selected message(s) to a folder, and assigning a shortcut key to that service. First create a Service in Automator for moving the selected messages to a specific folder.
  1. Open Automator
  2. Choose Service as your template.
  3. Set the top drop-downs (for Service receives...) to 'no input' in 'Mail'
  4. Drag the Run AppleScript action into the construction area.
  5. Insert the following AppleScript, changing fastmail to the name of your account, and ---Archive to the name of your target folder.
    on run {input, parameters}
      set target_account to "fastmail"
      set target_mailbox to "---Archive"
      tell application "Mail"
        set theSelectedMessages to selection
        repeat with theMessage in theSelectedMessages
          tell application "Mail"
            move the theMessage to mailbox target_mailbox of account target_account
          end tell
        end repeat
      end tell
      return input
    end run
  6. Save the Service as Archive message
Next, assign a keyboard shortcut to the Service:
  1. Go to the Keyboard Shortcuts tab of the Keyboard pane in System Preferences.
  2. Select Application Shortcuts in the left-hand column.
  3. In the right-hand column, hit the plus sign and add a shortcut with Application set to Mail, and the Menu Title set to Archive message, then set the Keyboard Shortcut to whatever you like.
It's an ugly, awkward, roundabout solution, but it seems to work.

[robg adds: As written, this script will move messages into folders that are associated with the specified Mail account -- that is, you've created a folder named Archive within the account 'fastmail' in your Inbox. If you'd rather have it file messages locally, to a folder in the On My Mac section of Mail, just remove the of account target_account bit from the end of the move the theMessage... line. I tested both versions of the script, and they work as described.]
    •    
  • Currently 3.15 / 5
  You rated: 5 / 5 (26 votes cast)
 
[17,179 views]  

10.6: Move messages to a target folder via keyboard shortcut | 10 comments | Create New Account
Click here to return to the '10.6: Move messages to a target folder via keyboard shortcut' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Move messages to a target folder via keyboard shortcut
Authored by: sig eigei on Nov 30, '09 09:40:38AM

I would suggest another shareware app for this, noting that, true enough, it will cost a little money: MsgFiler. It is super fast for those who are keyboard-centric. It's not so expensive. It has saved me so much time and it permits me to organize my mail into 100s of folders without a big headache, or drag/drop. (I'm not affiliated with MsgFiler - I just like it.)



[ Reply to This | # ]
10.6:MsgFiler rocks
Authored by: rodneyweston on Dec 02, '09 01:27:31AM

This is a good suggestion! After seeing your comment, I downloaded MsgFiler, and I love it... (after only 24 hours!). I'lll test it for another couple of days, but then I reckon that the dev will deserve his $US 8!

Thanks....



[ Reply to This | # ]
10.6:MsgFiler rocks
Authored by: sig eigei on Dec 02, '09 10:25:36AM

Yeah - it's a great addition to Mail. And, note that you can use keyboard shortcuts for Move and Copy and Open Mailbox as well as the arrow keys to navigate the list - those are the real time savers.



[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: digs0 on Nov 30, '09 05:21:15PM
Great tip. I've tried to achieve this using only customized menu commands for the mailbox names, but I always have to jump start the commands by using the actual menus first. This tip seems to work well, although Automator is a bit on the slow side. For a nested mailbox on my Mac, I had to indicate the path with slashes to make this work. So instead of
    set target_mailbox to "Correspondence"
I had to change it to
    set target_mailbox to "Messages/Correspondence".
---
DJR
---
DJR
Edited on Nov 30, '09 05:28:08PM by digs0


[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: mdmac on Dec 01, '09 11:19:32AM
I'm having trouble with this and I'm guessing it's in my interpretation of "change fastmail to the name of your account." I attempted to get this to work by replacing target_account with the "Description" of one of my accounts found in Mail>Prefs>Accounts . But it doesn't work. Also tried changing target_mailbox to "Mailboxes/Archived Messages" to no avail...

I have many email accounts and I don't know why this script would care about the account name if all I'm doing is moving selected message(s) (from whatever account) into an "Archived Messages" folder, "On My Mac" in Mail.

[ Reply to This | # ]

10.6: Move messages to a target folder via keyboard shortcut
Authored by: Swordfish on Dec 13, '09 06:45:08PM

As robg said, delete the "of account target_account" bit from the end of the "move the theMessage…" line.

Also, if you mailbox is in the top level, don't add "Mailboxes" in "Mailboxes/Archived Messages". I have a top level mailbox called "Archive" so I simply entered "Archive" in the script. But if "Mailboxes" is a folder you created then don't change that line.

Edited on Dec 13, '09 06:48:40PM by Swordfish



[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: HitsvilleUSA on Dec 20, '09 09:52:20PM

This tip is great. I only wish that there was a way to make it run a little faster...I find myself already moving on to the next message before the script completes, causing the wrong message to get "filtered".

Anyhow, I made some changes to the script because I have 3 different Gmail accounts all under "Inbox" and I want the emails to be filed into their respective "archive" folders. This is what I did:


on run {input, parameters}
	set target_mailbox to "[Gmail]/All Mail"
	tell application "Mail"
		set theSelectedMessages to selection
		repeat with theMessage in theSelectedMessages
			set target_account to name of account of mailbox of theMessage
			
			tell application "Mail"
				move the theMessage to mailbox target_mailbox of account target_account
			end tell
		end repeat
	end tell
	return input
end run


[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: estnyc on Dec 21, '09 05:23:15PM

Hitsville, when working with Gmail accounts in mail.app, as you're doing, there's a much easier way to archive messages. When you define your Gmail account in mail.app, make sure you do the following:

1. Under "Mailbox Behaviors," for Trash, make sure both options are unchecked. You want mail not to move deleted messages to the trash, and not to store them on the server.

2. For Junk, check "Store junk messages on the server." In the listing of GMail's folders within your mail.app sidebar, select the "Spam" folder and choose it as mail.app's Junk folder by selecting "Use this Mailbox for.." under the Mailbox menu, and selecting "Junk." So you want mail.app and Gmail to be using the SAME folder for Junk and/or Spam.

Once you've done this, you can easily archive messages without any custom scripts or plugins. When you're going through your inbox, to archive a message, simply delete it. As Gmail uses tags, not folders, you're not actually telling Gmail to delete the message, but rather remove the "Inbox" tag from the message. Without the "Inbox" tag, the message will no longer show up in your Inbox, but it won't be deleted from your account; it's still accessible under "All Mail."

This is exactly the same as clicking on the Archive button for messages when you're using gMail's web interface.

OK, so deleting == archiving. It's not intuitive at first, but it's sure easy to remember and quick to perform.

If deleting is archiving, you may be wondering, what should you do if you really want to delete a message? This is also simple, but not initially obvious.

Flag the message as junk mail. Mail.app will move the message out of your Inbox and into your Junk folder, which also happens to be Gmail's Spam folder. In other words, when you click on a messages's Junk button, you're telling gMail to remove the "Inbox" tag from the message, and apply the "Spam" tag. So the message will show up in your Gmail account's "Spam" folder, and it will be automatically deleted when it gets to be thirty days old (the age at which Gmail automatically deletes Spam messages).

So, to archive, delete. To delete, junk.

It really will make sense, I promise.

The problem is if you have any accounts in mail.app that aren't Gmail account. If you try to archive mail from one of those accounts' inboxes by deleting it, you'll be in for an unpleasant surprise.



[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: Toiddles on Jul 25, '10 11:19:46PM

Makes sense except flagging a message as junk hurts the sender.



[ Reply to This | # ]
10.6: Move messages to a target folder via keyboard shortcut
Authored by: gugavieira on Feb 07, '11 02:23:28AM


Actually I was looking for a way to keep the default gmail behaviour of archiving messages (since I archive much more than I delete) and add an method to delete them (or just automate the "move to gmail/trash folder").

I could use the beginning of your tip to keep the behavior and was thinking about something like MailAct-on with a shortcut like "Cmd+Delete" for when I want to get rid of the message. So it would work like Delete key = archive and Cmd+Delete = delete.

Any tips on a way to automate my "move to gmai/trash folder"?

Does it make sense?



[ Reply to This | # ]