Capture a File Path

In case you missed it, you can try the Automator Workflow from above.

Thanks. We were all posting at the same time. Your post wasn’t there when I made mine.

Not in my version of El Cap

To recap, thanks for all the fast responses. Yesterday got away from me and I am just back to this now. First, the developer released an update so the problem I was having no longer needs an independent solution as I was asking for here. It is still a good question and when I figure it out I will enter it into my own personal notebook of tips for the next time.

I looked in KM for any command that seemed relevant before I posted here. I didn’t see one.

Not interested in Automator, thanks. Not a fan of pure AppleScript solutions. Will use AS inside of a KM solution or where needed - IF needed but it is definitely not my first choice.

I learned a lot from Dan’s example. Thanks all for the fast response and the great support.


Oops, I spoke too soon, this does not convert a file path so that it may be clicked to launch the file. It does not convert/escape the spaces. Somewhere in this process there needs to be a replace spaces with a "/ " or some such.

Trying this but getting the variable is not defined.

1 Like

Make sure, that the Service is activated in System Preferences > Keyboard > Shortcuts > Services.

Edit: Also, the Context Menu is context-sensitive. So not all Services will always be there.

The AppleScript in your macro doesn’t make any sense to me, and/or parts of the macro seem to be missing.

Why don’t you try it with @Dan’s example from above?

You can do this by adding a Search/Replace action to the macro.

I did and it worked perfectly - except the result was not clickable. The solution was something I copied from an example on Stack Overflow. I may have misunderstood the example. It was given in context of solving this problem and I assumed the finder command was something built in to set a path to a correct POSIX value. Apparently not though.

Thanks, for some reason "restore defaults" puts in all sorts of what I consider to be non default junk, items from Graphic Converter, Devon Think and other apps that don't use very often.

Clearing the clutter except for the copyfilepath put the command on the option popup menu again. Thanks.

For “clearing the clutter” use the Services Manager app. Gives you a big window and some more options.

Once the context menu is up, hold down the Option key. It changes the menu form this:

to this:

Notice the "as Pathname" at the end.

Not sure what you mean with “clickable”.

In your other post you said you want to escape the spaces. You can do this with a Search and Replace action. If the path is clickable depends on where you paste it in.

Or do you want a file URL? A file URL is like this:

file:///Users/tom/_Tmp/untitled%20text%2010.html

Thanks

Dan, this doesn’t escape spaces. At least not on my Mac.

Yes, that is what I meant and yes, I just took that earlier suggestion. Now, everything works. Thanks

No, I was just answering the question about how to get the "Copy as Pathname" menu item to appear.

Yes, sorry, I thought his initial question was how get the path with escaped spaces :wink:

1 Like

OIC, Thanks. I use a Microsoft (non apple) split keyboard. I also had a hacktosh for years so I still get a little confused when I say option, command, etc. Thanks for pointing this out. I forgot that Apple does have added levels on menus with the right key presses.

Funny - I almost typed “Alt” instead of “Option”, since I came originally from the MS world. :slight_smile:

I know. My mind sees three modifier keys and remembers the pattern of order. The left one, the right one, the middle one - which is useful when I do work on a Windows system as I just mirror them (in my mind) or flip em over.

Yep. I have an Apple keyboard I use with Windows, so I do the same thing, in reverse. :slight_smile: