How Do I Use Current Browser URL and Title To Create a WebLoc file? and How Do I Rename Forklift Files?

Hi guys, glad to be in here. Only just installed the trial of KBM and I'm looking to find out if two things are possible:

  • When in any web browser (Brave or Vivaldi usually) is it possible to copy a URL shortcut to the desktop but have the URL named as per the page title with non-alpha numeric characters stripped out?
  • Select a group of files (preferably in Forklift) and rename them based on a set of rules (similar to what Forklift can do) but with a more reliability?

[Edit - Pathfinder corrected to read Forklift]

Hey Daron,

Yes, these tasks can be accomplished, although the Path Finder bit will be a trifle clunky.

What version of Path Finder?

What version of macOS?

-Chris

Thanks for responding. I mistyped actually it's Forklift 3.4.4 not Pathfinder I'm using, and MacOS Big Sur..

Hey Daron,

Here's how to create a bookmark file in the Finder:

Create WebLoc File in Finder from Brave Browser.kmmacros (8.0 KB)

I've used AppleScript to specifically get the page title and URL from Brave, and this method should work with Vivaldi as well by substituting 'Vivaldi' for 'Brave Browser' in the AppleScript.

You can also use the front browser URL token like so:

Keyboard Maestro Actions.kmactions (1.2 KB)

I replaced NON-word characters in the title with bullets (•), so you could easily see them. Change them to suit yourself.

-Chris

Hi Chris, the first macro works perfectly apart it will only execute when I hit the Run command in the Editor. Hitting F1 (or any other hotkey I try) seems not to execute it at all. Newbie time I guess. What am I missing?

Hey Daron,

As for ForkLift...

It has only the most rudimentary AppleScript dictionary, so you basically can't do jack with it.

However – Keyboard Maestro can often make the impossible possible on a Mac.

Quick Select works quite well in ForkLift and supports regular expressions.

⌘S

Quick Open give access to various commands, saved rename specifications, and suchlike.

Escape

You can also assign a keyboard shortcut to 'Copy Path to Clipboard', copy the paths of the selection, and then use AppleScript to operate on those files in the Finder.

So you can make ForkLift behave more the way you want it to.

-Chris

Grr.

You probably need to toggle Keyboard Maestro accessibility permissions. See this:

Let me know if that fails to solve the issue.

-Chris

1 Like

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hi dbrewood, welcome to Keyboard Maestro (KM) and its Forum.
KM is one of the best Mac automation tools available, its Forum is one of the best and friendliest forums on the Internet. Whenever you reach a tough stumbling block trying to use KM, please feel free to post your question/problem here for help.

You will also find this helpful:
Tip: How Do I Get The Best Answer in the Shortest Time?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the future, please post each question as a separate topic, with a Topic Title that reflects the nature of the question.
This time I have changed your Topic Title to reflect both questions.

Hi Chris, alas no difference at all. I can have Brave fronted and with the Editor open hit 'Run' and it works perfectly. If I hit the F18 I selected to run the macro nothing at all. Interestingly enough if I change the hotkey to a KBM key I already have assigned instead of getting the choice popup it just executes the original macro I assigned.
Thought - to import the macro I just double clicked on it, should I have done it some other way? Also if I click on 'Enabled Macros' it is not in the list, but as far as I can see it looks to be enabled? Or again I'm missing the obvious.

[quote="JMichaelTX, post:8, topic:20322"]
You will also find this helpful:
Tip: How Do I Get The Best Answer in the Shortest Time? [/quote]

Thanks duly noted :slight_smile:

Again my thanks, newbieness will wear off :slight_smile:

I fixed it, I created a new group 'My Macros' and dragged it into there and it now works :slight_smile:
Thanks muchly!

Hmm...

I suspect when the macro imported the Macro Group 'Test Group.ccstone' was not enabled. That's a safety feature in Keyboard Maestro.

Look in the View menu for 'Enable Macro Group'/'Disable Macro Group'

You'll probably want to make a Brave Browser specific Macro Group, so your related macros are only available in the app – otherwise they'll be global.

-Chris

Hi Chris, correct that was what the issue was :slight_smile:
I have now set up a Brave group as you recommended. :slight_smile:

The only 'slight' issue that I have, which I don't think can be fixed, is that of the '.webloc' extension being on the file created. I I dragged a URL onto the desktop the shortcut created does not have the '.webloc' on it at all so looks much neater. I can live with it of course and I'm not complaining at all. Just it'd be neater not to have it visible.
It's weird as if I look at both types of shortcut in Finder they both look the same and both show the extension, just the ones dragged there do not show '.webloc'. Macs are weird!

:sunglasses:

Is this setting on or off on your system? It's in the Finder Preferences – ⌘, in the Finder.

image

-Chris

It is indeed:
image

The three top ones are created with the macro, the bottom two dragged and dropped. Oh macro modified to save to desktop...

image

Okay, in that case we can fix it.

Try this updated version.

-Chris


Create WebLoc File in Finder from Brave Browser v2.00.kmmacros (7.3 KB)

1 Like

Many, many thanks Chris, that works absolutely perfectly! Made my morning that has!

1 Like

@ccstone an interesting one to note this morning. I've modified the macro to work with Vivaldi (same issue applies in Brave though) and for some pages like this one, the webloc shortcut is created, but when looking to click on the desktop to open it Safari executes and fails to load the page. Other YouTube videos seem fine.....
I've experimented with using the same Macro in Brave and Vivaldi and both exhibit the same issue. Weird. Anyway I thought it worth feeding back...

Hey Daron,

Hmm...

After doing some detective work it seems that Apple's .webloc files prefer that HTML entities be encoded.

In the case of your YouTube video:

https://www.youtube.com/watch?v=uuHVrtRqbrQ&feature=youtu.be

Needed to be converted to:

https://www.youtube.com/watch?v=uuHVrtRqbrQ&feature=youtu.be

I've fixed this in the macro by adding the appropriate Filter action for the URL.

I've also made the macro browser-agnostic (to a point) – it now supports Safari and all Google Chrome variants that Keyboard Maestro's FrontBrowser token supports.

-Chris


Create WebLoc File in Finder from Front Browser v3.00.kmmacros (8.4 KB)

2 Likes

@ccstone

Chris you are a complete and utter star!

I didn't think a fix would be possible, but to achieve that and also to make it browser agnostic is awesome!

Thanks very much!

1 Like