Looking for a utility for super-basic on-the-fly text processing stuff

I wind up with a bunch of random copy/paste stuff I have to clean up. One example is Amazon URLs. I seem to send them to people quite a bit, and the URLs always seem to be a bazillion characters long. The actual URL of the product is a tiny fragment of that, and I’d like to be able to have a little utility to auto-clean it somewhere in the process.

Apart from doing something weird in Keyboard Maestro, is there any software I should be looking at?

Brett Terpstra used to sell an app that cleaned up Amazon links (among other things), but it seems to have gone to the Great App Store in the Sky. So I recommend something weird in Keyboard Maestro, namely a search-and-replace with a search regular expression of


and a replacement of


Like this:

That will turn this URL,


into this:


I’ve been using this regex for ages, and it’s always worked.


Shortcuts can extract url components. Might be worth waiting for monterey.

That’s interesting. I could map Cmd-Option-C or something to the “fancy copy”, and the conflict palette would let me have multiple options for cleanup.

Thanks for the regex!

If its just for Amazon links you might want to setup an affiliate link. Once established you will see a small extra toolbar with a share button on the left hand side. Select text and you will receive a short url :wink:


Also you can easily create a page on your website with the various products you often recommend to your clients :wink:

Most of these aren’t specific recommended products, but rather a client looking for something and me just trying to point them in the right direction. Either that or me communicating with my girlfriend about which dog vitamins we need to buy. :smiley:

I use the Bitly extension in PopClip – select the URL in the location bar in Safari. (There are other link shortener extensions for PopClip.) This is what the extension puts on the clipboard:


(The example has been anonymized.)

Does that strip out the offending garbage at the end of the link? Or does it just shorten it for clipboard purposes?

I’d prefer to strip it all out because I prefer to not have any more Amazon tracking nonsense following me around than necessary. :slight_smile:

It’s just a URL shortener – when expanded by Amazon when the URL is clicked you’re back to the original long and indecipherable URL.

I suppose the real question is: is it possible to get an URL linking to product on Amazon that is just a direct link to that product with no other hidden info in the URL? I suspect the answer is “no”, not unless you do what @drdrang suggests.

I agree that this is a darling job for regular expressions. Either in Keyboard Maestro if you want a shortcut to process one entry at a time, or, if you want to paste in a lot of entries and batch process them, then something like BBEdit (very fast/robust editor for large text files, with a great find/replace window), RegExRX (most robust regex-specific tool for Mac that I know of), or CyberChef (free tool for all sorts of data manipulation including regex replacement).

I usually create Alfred workflows for things like this.