Macro Does Not Work : Insert File Name and Path

Hello, even if you don't know Scrivener, it's no problem. I must be making a basic mistake.

I start off in a Scrivener document → reveal Scrivener file (called project) in Finder → copy the file name and POSIX → return to Scrivener to paste the info

I must be making a very basic error which I cannot identify.

thank you very much

insert type file location path info.kmmacros (6.5 KB)


Either you or me is making a basic error. And it might be me. But in each case below you are assuming that the Select Menu action saves data into a variable.

I'm going to give you the benefit of the doubt that you have some program called Path Finder (that I've never heard of) which uses its menu system to save path information into a KM variable whose name shows up in its menu system. If that's possible, then I would say your bug is that you are copying the same string into both of your two variables.

You aren't telling us what's happening here. You said it isn't working. Why isn't it working? What is the false result? Are you getting empty variables? Is nothing being inserted at all? Is the macro aborting? Does your computer catch fire? (That last one was a joke.)

1 Like

Thank you for your reply.
The select action copies to clipboard which I then copy to a variable.
Does not work means that name and UNIX path are not typed in at the end.

Okay, understood. In that case I have to google what this "Path Finder" app is that you have and what its menu system does. I'm doubtful that it populates KM variables, but I could be wrong. My guess at this point is that you are under the wrong assumption that the Path Finder app populates KM variables.

1 Like

Oh! I think I see your problem. The actions that you think are copying to a variable are doing the exact opposite. They are overwriting your clipboard WITH variables.

You need to do the opposite, using the Set Variable to Text action inserting the Clipboard.

Is that a sufficient hint, or do you need me to write the code?

If I was as smart as the wizards on this forum, I probably could have solved this issue faster. Thanks for your patience.

1 Like

Thank you for your suggestion which I implemented.
Let's go to the core of the problem. Why does the following not display the name ? (note that I changed to set variable to text as you suggested).
the literal text %Variable%Name% is displayed instead of the actual name
thanks again


The likely reason is that your clipboard probably already contained "%Variable%Name%" due to the PREVIOUS bug which we now fixed.

Put this action directly after your first action. If you are not seeing the file name here, then that's your problem. I can't prove what Path Finder does to the clipboard because I don't have it, but I'm not sure it does what you think it does.


red steps:
1- displays the file name correctly
2- displays the text (literally) : %Variable%Name%

the problem must thus lie with either 1 (clipboard value not passed to variable) or the syntax of 2

thank you


When I take PathFinder out of the macro (which I have to, since I don't have PathFinder) the remaining code works perfectly for me.

So I have a clue what might be causing it. Some apps put some hidden things into clipboards. To be honest I have no idea what that means. It's been discussed in several threads on this board in the last few days. An update to KM is coming up very soon that addresses this issue.

So I admit defeat here, unless I'm right about this clipboard bug which is being addressed right now by Peter.

1 Like

OK thank you very much for your time and help

You are welcome, and I'm sorry I couldn't solve your problem. But maybe I did, depending on whether the imminently arriving patch fixed your issue.

I think that it has something to do with naming variables.
Hello @peternlewis. I am sure that it has something to do with variables but we are stuck. Your help would be greatly appreciated.

Ok, and my thought is that the bug is in the Green #1 action which is bugged for the reason of hidden information in the System Clipboard placed there by Path Finder that is a known issue and is about to be fixed. but if I'm wrong, I'm wrong.

I think I've identified the issue. PathFinder requires some time to actually put the file path on the clipboard, so you need an Action Block like this:


Here's my example macro using BBEdit (since I don't have Scrivener).

MACRO:   Insert Name and Path of Open File Using PathFinder [Example]

~~~ VER: 2.0    2019-08-21 ~~~
Requires: KM 9+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Insert Name and Path of Open File Using PathFinder [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.




  • Demo How to Get Path Using PathFinder


  1. Open File in BBEdit
  2. Position Text Cursor on New LIne
  3. Trigger this macro.


Thank you VERY much. Works perfectly.
I want to seize the opportunity to read about the variables and actions 2 and 3 below. 1 I understand is an action group.


Thank you for finding the problem, ie clipboard change issue.

I would greatly appreciate your critique of my approach which does not involve the CLIPBOARDSEED() variable. It works, but I would like to know if my unsophisticated approach has pitfalls or limitations.

thanks again very much


the macro navigates from Scrivener to pathfinder back to Scrivener
Is there any way to avoid having pathfinder flash on the screen ? could I remain in Scrivener and have the pathfinder related actions happen in the background.
The reason for my question is to better understand KBM, not yet another caprice
thank you

The issue with your approach is that you are assuming that the Action setting the clipboard with NOT ever set it to "1".
Why not use the CLIPBOARDSEED() function which will work in ALL cases?

1 Like

No. Not as long as you are using the KM "Reveal in Finder" Action.
Frankly, I would never use your basic approach.
In your other topics, @ccstone, @tom, and I have all shared with you much better ways to get the POSIX path of the current open file in an app.

1 Like

thank you. Your version is certainly the best and the one I will use. My simplistic version is simply a step for me on the way to better understanding KBM programming