Browse the docs

finder.selection

The paths of the items selected in the Finder, one per line.

Keyboard Maestro: FinderSelections

Details #

{{finder.selection}} is the Finder's selected items as POSIX paths, one on each line, read at the moment the step runs. With nothing selected, or when the Finder can't be asked, it is empty text. It is what an imported Automator Quick Action receives as its input when the action takes files or folders.

Reading it asks the Finder through AppleScript, so the first run may ask for permission under System Settings › Privacy & Security › Automation. It is the same value as finderSelections(); the token is the shorter way to write it in a step's text.

A run variable called finder wins over the token.

Parameters #

Write it as {{finder}} in any text field. A variable of the same name wins.

Examples #

finder.selection
→ /Users/me/a.txt /Users/me/b.txt
Sample variableValue
finder{"selection": "/Users/me/a.txt\n/Users/me/b.txt"}
Open the selected files in TextEdit (runs a shell command)
When
  1. Press ⌃⌥O
Do
  1. Run shell script “while IFS= read -r f; do open -a…”
Open in Switchboard to try it

Gotchas #

  • Paths are separated by newlines, so a path that itself contains a newline can't be told apart. That is rare.

  • A shell step gets the paths on standard input (input), one per line: read them with while IFS= read -r f; do ...; done.

See also #