Browse the docs

finderSelections

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

Keyboard Maestro: FinderSelections

Details #

finderSelections() takes no arguments and returns the POSIX paths of every selected item in Finder as text, one path on each line. Nothing selected gives empty text.

To work through them, split on the newline.

Parameters #

Takes 0 arguments. {{ finderSelections() }}

Examples #

finderSelections()
→
length(split(paths, "\n"))
→ 2
Sample variableValue
paths/Users/a/one.txt /Users/a/two.txt

Gotchas #

  • It asks Finder through Automation, so Switchboard needs permission to control Finder. If that is denied it returns empty text.

  • A path that contains a line break would split in two; this is rare.

  • Calling it with any argument is an error: finderSelections() takes 0 arguments, got 1.

  • When no real Mac is behind it (tests, previews) or the Mac can't answer, it returns empty text.