Automator to create Project folders in finder and new mailbox

I have cobbled together an Automator script(?) / macro to create the standard set of folders I set up when I start a new project / job.

I also get it to open a new Mailbox in for the new project / job in my current “Matters” mailbox in (The new Mailbox is a sub Mailbox in the “Matters” mailbox of my work account.

I would like the name of the new Mailbox to be Matters/fileName where “fileName” is the variable I enter at the start of the script / macro being the name of the new project.

Is this something that is feasible? The script/macro just creates a new Mailbox called Matters/fileName. (For some reason, it also adds an extraneous folder “007 Motions” in “008 Documents”.

Any help or direction where to find the instructions for reusing a variable from Automator into an AppleScript would be much appreciated please.

Ideally, the new mailbox would just be “fileName” without the Matters/ prepend. However, it doesn’t seem like anyone on the Internet has been able to achieve this. Also, it doesn’t seem to be possible to automate renaming the new Mailbox. Even manually selecting the new Mailbox and renaming doesn’t change it.

1 Like

Your script had all the pieces. It just needed some small adjustments. Try this:

on run {input, parameters}
	set matterName to first item of input
	tell application "Mail"
		tell account "VicBar"
			set fullName to "Matters/" & matterName
			make new mailbox with properties {name:fullName}
		end tell
	end tell
end run

Your script tries to set input within the on run handler. But you don’t want to set input; it already contains what you want from the previous Automator step. The tricky thing is that input is defined as a list (even though it has only one value), so the name of your new mailbox is input's first item. As you can see, I created the variable matterName to hold that string. Then I built fullName as a sort of path with the container mailbox and passed that as the name property of the new mailbox.

I tested this on my system with my FastMail account and it worked fine—no slashes in the names of new mailboxes.


I’ve read that slashes appear in the new mailbox name of Exchange accounts, but I can’t test that, as I don’t have an Exchange account. Also, that thread is now several years old and may not be true anymore. If it is still true, I’m afraid I can’t help you with that part.

Magic! Thank you.

I am afraid in Exchange one does get the Matters/ component of the name rather than the preferred outcome you illustrated in Fastmail.

It seems, however, something to do with Exchange. None of the other attempts I have come across searching the Internet have been able to avoid this outcome although, as your test illustrated, it doesn’t happen in other types of account.

I am afraid I am stuck with Exchange as it is a work provided service.

Thank you once again!

Setting aside the sub-mailbox issue, were you able to use this script to create mailboxes that appear in Exchange and get synced to other clients?

When I use applescript to create a new mailbox inside my Exchange account, the mailbox never gets pushed up to the server, but only ever appears on the mac on which it was created.

I haven’t used it for awhile as I was trying to get the new mailboxes to line up in an existing Mailbox folder. I shall test it again over the weekend.