"Filter" Action - Documentation for each "Filter"?

I was just looking at the "Filter" action, and the description of the available filters. There's no explanation for any of them, that I can find.

(By the way, even without an explanation, you should really take a look at the available filters, because there's some amazing things there.)

Here's the list, and I'm hoping you guys can add explanations, which maybe I can colate into something for the wiki. I've bolded the ones that aren't obvious:

  • Remove Styles (clipboards only, make the clipboard plain text).
  • Set line endings to Mac (CR), Unix (LF) or Windows/DOS (CRLF).
  • Trim Whitespace. (Remove leading and trailing whitespace from a string.)
  • Hard wrap or unwrap paragraphs.
  • Lowercase (all characters), Lowercase First (just the first character).
  • Uppercase (all characters), Uppercase First (just the first character).
  • Capitalize (all words) or Title Case (intelligently uppercase certain first letters).
  • Sentence Case (first character of each sentence) (v11.0+).
  • Change quotes to Smart, Dumb or French quotation marks.
  • Encode HTML or non-ASCII HTML entities.
  • Encode HTML with numeric entities.
  • Decode HTML entities.
  • Generate an HTML list.
  • Percent Encode or Decode a URL. Percent Encode will encode all non-alphanumeric characters.
  • Encode for Regular Expression.
  • Encode or decode Base64.
  • Calculate MD5.
  • Styled Text to/from RTF plain text (v11.0+).
  • Quote for AppleScript, JavaScript, Shell (bash) Script, Swift, JSON or Process Tokens.
  • Convert a JSON object string to Compact or Pretty format.
  • Get parent of a path.
  • Get the filename component of a path.
  • Get the base name of the path (ie the filename without directory or extension).
  • Get or delete the path extension.
  • Get the display name of a path.
  • Expand tilde (~) paths, or abbreviate with a tilde.
  • Resolve symlinks, or standardize the path.
  • Get the URL scheme, host, port, user, password, path, fragment or query.
  • Sort, reverse (first⇔last), or shuffle (perpetuate) lines.
  • Delete or bullet (•) control characters.
  • Calculate an expression and return the result, see the Calculations section.
  • Process Text Tokens and return the result, see the Tokens section.
  • Get the value of a named Variable or Named Clipboard.
  • Count the characters, words or lines and return the result.

It's not obvious, but "", "a", and "a\n" all return a line count of one. (I would have preferred that they return values of 0, 1 and 2.) It's not mentioned in the wiki, but there's a link in the wiki to a forum page that discusses this issue.

1 Like

"Hard wrap" splits text at word boundaries to keep line length below 78(?) characters but as long as possible. The Filter does this by replacing the latest possible "horizontal space" character, for example a %Space% or a %Tab%, with a return character (%Return% or \r). Good for creating "fixed width" text blocks from "normal" text.

"Unwrap" replaces any %Return% or %LineFeed% it considers to be "mid-paragraph" with a %Space% character. ("Mid-paragraph" appears to be when the return/line-feed character is not followed by a %Space%). Good for creating "normal" text from fixed-width blocks.

Both variants seem to work equally as well on rich text as on plain.

Can be considered to be the same as "the name of an item as displayed in the Finder when 'Hide Extension' is turned on in the item's 'Get Info...' window".

Essentially, the text in a path between the final / (or between the penultimate and final /s if there's a trailing /) and the final .

Path Display Name
Users/me/Desktop/testFile.txt testFile
Users/me/Desktop/testFile.txt.zip testFile.txt
Users/me/Desktop/testFolder testFolder
Users/me/Desktop/testFolder/ testFolder
Users/me/Desktop/test.Folder/ test

Watch out for that last one if you are in the habit of using .s in folder names!

Extracts parts from a URL.

While a URL needs only scheme, :, and path, most consist of more. So for the URL


...the various Filters will return:

Filter Option Will Return...
URL Scheme http
URL Host www.example.com
URL Port 80
URL User username
URL Password password
URL Path /path/to/item.html
URL Fragment fragment
URL Query param1=value1&parm2=value2

Filter – Generate an HTML list

Maps a list of text lines like:


to either:

  1. complete (terminated) <ul> sequence if the source lines end with a blank line (as above):
  1. an unterminated <ul> sequence, open for further <li> additions, if the source has no trailing blank line.

Generate an HTML list.kmmacros (4.8 KB)

1 Like

Maybe I'm missing the obvious, but what would you use this for, in KM? I mean, I understand what HTML lists are, but this seems like an obscure thing for KM to offer.

Not sure what the specific context or history is there.

(I personally have something similar for generating the nested <ul><li> of Bike Outliner HTML from tab-indented lists, but that's fractionally more specialised)

@peternlewis ?

1 Like

I think this corresponds to the (localisation, user file extension display preferences etc) discussion section here:

displayNameAtPath: | Apple Developer Documentation


I've been wrong a few times before, so I could be wrong again, but on this page, the word "perpetuate" probably is a type for "permute". Even with that fix, the word "permute" is very vague. Permute the letters in each line? Permute each line in the file?

1 Like

Probably "type" is a typo for "typo" :wink:


That's a bug, it should always have a trailing </ul>.

As to why it exists, I guess it seemed like a good idea at the time.