Error – "Can't Find Folder Path" – in Saving Emails as PDF

I use a number of macros to save emails as PDF. They all use the same basic workflow:

  1. Remove a tag.
  2. Use the menu item to save the document as a PDF.

The second step always seems to work correctly but some macros do not remove the tag. When I look at the log the error appears to be due to "Cant find folder Path"

To test the function of removing the tag I truncated one of the macros to reduce it to only removing the tag, see below. This produced the same error of "Cant find folder Path"

It would appear that I'm not configuring something correctly.

Any suggestions as to the source of the problem and how to fix it.


Filing Emails.kmmacros (9.1 KB)

Hey @dorich,

You haven't defined the variable “Path” anywhere,

If you don't delete that variable later or use a local variable then it will be reused by any macro that employs “Path” as a variable.

This is potentially very dangerous.

If you want more help you'll need to provide an actual “working” (even if broken) macro for people to test with.


Edit 2019/07/14 – Macro file now available in Post #1 – ccs.


Thanks for your response.

I have a couple of questions:

  1. How would I define the path? I see that the path is associated with the email so in my naivety I'm assuming that KM has to gather that data from the item in question. I don't know how to get the path data and then define the variable.
  2. Is there a method in KM Editor to capture the image of a full macro before its uploaded to this forum? To comply with your good suggestion I wanted to upload a working macro and a non working macro but that would need some redaction before posting.


Hey @dorich,

What path?

The email's path? The path of the newly printed PDF?

Please be specific.

Your workflow description is a bit confusing, because Mail does not support tags – therefore your item (1) makes no sense.

Yes – please see this:

How to Post Your Macro to the Forum

If you have any questions after seeing that then please ask away.



The answer to your question is the email's path. Apologies for the lack of clarity. I truncated the section dealing with saving to pdf so in the example image I posted the only function is to remove the tag "alert" from the target email.

Thanks for the pointer regarding getting the image.

I'll post a couple of images of working and non working examples that I'm using.


Macro - Success

This macro works. It removes the tag and saves the pdf in the correct location.

Macro - Fails

This macro does not remove the tag but it does save the pdf in the correct location

Hey @dorich,

When posting a macro to the forum please post BOTH the image and the macro itself, so people have something to test without having to reinvent the wheel.


Hey @dorich,

That can't possibly work properly.


You're using Path twice here, and that's bad news indeed.

Change “Path” to “pathStr” in the for each part of the statement.

Change “Path” in the directory to a real path to a real directory like:


Moving on...

There are NO tags whatsoever to work with in a Mail message – Mail does NOT support tags, so what tags are you talking about? (Finder-tags I presume.)

Mail does NOT make the path to an individual email message available anywhere, so it's quite impossible to capture anything useful to “Path”.



Thanks for your response.

I'm obviously out of my depth here.

I can only say that the "success" example I posted (apologies I didn't post the macro) works perfectly . I use it monthly and have done for a few years. So in my naivety I can't explain why it works, but it does. I have a few other variants of the "success" macro and they work perfectly.

With regard to tags assigned to an email. I use "Mailtags". I suppose you might term it a plugin for apple's Mail application. Once again I can verify that for the "success" macro posted and for a number of other macros I can add and remove tags using the code shown in the example I posted.

I'll post the working macro later today.


It's always delightful when someone delivers a surprise to one of the wizards here. They are human after all. But we haven't seen both sides in full detail yet so it's not perfectly clear who might be right here.

Don't worry about being out of your depth. I'm often out of my depth too here. It's still a good place to be. You've been perfectly polite so there's nothing to worry about. You've got one of the wizards helping you so an answer should be forthcoming.

Since I'm a latecomer here to this thread I'm not sure if you posted the working macro in an older post above or if you are still planning to post it.

Thanks for your response and encouragement.

It's entirely possible that what I have is only working by some fluke but whether its a valid approach or not I can verify that it does work. I've used it hundreds of times and it always produces the correct result with the emails correctly tagged and sent to the archive. And, the pdf export arrives in the correct folder (where it is subsequently processed by Hazel).

Alright. So your question is why are some of your macros giving you the error "Can't find Folder Path". And you say this last one doesn't give that error.

What you did (to help us) was show us some "working macros" that are very similar to your non-working macros. Looking at your working macro may not tell us why your non-working macros aren't working.

One time I told my doctor that my left ear wasn't working properly and he immediately looked at my right ear. I said "Doctor, that's the wrong ear." He said, "I know, I just want to establish a baseline first."

So sometimes having a baseline can be useful. I'm not sure it's useful in this case. In this case my approach would be to look at the failing macro. It seems that you posted a very trimmed down version of the failing macro at the top of this thread, and a less trimmed down version of a working macro near the end of the thread. (But there doesn't seem to be a less trimmed down version of the failing macro anywhere - the one that gives you the "can't find Folder Path" error.)

We totally accept the fact that you must remove personal information from your macro especially financial information, and perhaps people's real names. But it can be problematic if you don't tell us which actions you edited out personal information from. My guess is that you edited out information from your directory path. But if I guess the wrong thing it may be impossible to find the solution.

Since your original post was asking about a "Can't find Folder Path" error, would it be possible for you to post a minimally trimmed down version of that macro? Ie, the one that we're trying to fix?

If this is frustrating, I apologize. If you do edit out any actions to remove personal information, that's fine, but can you tell us which actions you edited? Because there's a very real possibility that the stuff you edited out is the very stuff that's causing the "Path Not Found" error.


Thanks for your response and explanation.

I "attempted" to post the macro but it would appear the system got the better of me.
I couldn't see how to insert the macro into the current thread, I'm sure there must be a way.
Anyway I posted the macro to a new post and attempted to link to it but the post isn't appearing on the site so perhaps some clever software monitor didn't like it because I used the same title as my first post. I'll make another attempt to post the macro.

Keyboard Maestro 8.2.4 “Filing Emails” Macro

Here is the macro that works.

Filing Emails.kmmacros (9.0 KB)

No worries, I'm patient. I presume you are still going to post a macro that "doesn't work." You just posted a macro that you say "works." I'm sorry if I wasn't clear.