Show in Finder - for open file in any application

In some Mac applications there is the menu item or contextual menu item "Show in Finder".

I was wondering if it would be possible to use Keyboard Maestro to do a similar task for an open file in any application.

For example if a saved file is open in Preview I would like a Keyboard Maestro hot key shortcut to open Finder and highlight the actual file.

I know I can do this by right clicking at the top of the window's bar, on the file icon and then navigate to the file in finder. But I would like to be able to achieve the same thing with a hot key and ideally in any application, not just Preview.

I've tried a few approaches but I'm not getting anywhere.

As always, any help is much appreciated.

I have managed to make this macro, which works in Preview.

It used the "mouse click at found image" to open the menu and navigate to the enclosing folder. But it only works in Preview - because the found image is a Preview icon. And it doesn't feel like a very elegant solution as I would have to make a new macro for each application.

Hey Mark,

See this thread:

Finding the file path for an open document in the Front Application

-Chris

Thank you - I am trying the first macro in that thread now. I just changed the bit I highlighted in red, to reveal the file in finder rather than showing its path. I will try with a few apps. Thanks again.

Hey Mark,

Just so you know – you can use a “local” prefix with variable names, and they won't be saved in the global variable space.

This is sometimes inconvenient when developing a macro, because you might want to go back and check various variable values.

But – once your macro is complete you can say:

local_PosixPathOfFrontWindow

And then you don't have to %Delete% the variable later -- automatic housekeeping... :wink:

-Chris

1 Like

Hi Chris

That is interesting -

So, putting "local_" in front of any variable name means it won't be written to disk? Is it just stored for the time the macro runs?

And I am assuming %Delete% acts as a command in the last action, to delete the variable if it has been written to disk?

1 Like

Hey Mark,

Correct on both counts.

-Chris