Need Help Creating an URL on the Clipboard from a .Webloc File in the Finder

I am trying to translate an Automator action to Keyboard Maestro. The outline is this:

A URL as a .webloc is selected using For Each Item in a Collection Execute Actions.

And, here is where I'm having a problem. I need to pass the URL without the path component to the Applescript that converts the URL to a pasteable link like this.

I've attached the Applescript as a file. applescript.zip (1.4 KB)

Upon completion of the script's conversion the result has to be returned to KM in order to paste it into a document as the formatted link.

I use this now through an Automator script that I simply call from KM, but I would like to translate the entire macro to just KM and not need to use Automator.

Peter tried to help me out, but I was just not able to get it to work. I cannot figure out how to get the URL.webloc file into the Applescript nor how to return a result to the System Clipboard in order COMMAND-V paste into a document.

Thanks in advance to anyone who can give me hand.

Kappy

Hey Kappy,

Zip and post the working automator action and a couple of example .webloc files for testing.

-Chris

Thank you, Chris, for taking the time to help me out. The files you asked for are attached. They include the Automator script, the KM macro calling it, three example links.

Kappy

Archive.zip (1.6 MB)

Hey Kappy,

Boy the Automator Action was slow...

I managed to do everything in the shell, so this is quite a lot faster.

-Chris


Create RTF Link on Clipboard from Single Seletecd .webloc File in Finder.kmmacros (7.7 KB)

Chris,

Whoa! That’s super-duper. You completely re-wrote the whole thing. You are very generous. I don’t know how to repay you, but if you ever need a professional investment analysis of a commercial real estate project, just let me know.

The irony of all of this is that Apple just released the third round of the El Capitan beta where the original problem that started all this was actually fixed.

Thank you, again, for all your help.

Steve