Choose Filepath(s)

UPDATED TO VER 0.3
( adds custom prompt text for the choose file(s) dialog)

Section on Custom Plugins in KM Help File:

(note that to update a plug in action you must manually remove it from the ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions folder before re-installing it)

Choose File(s).zip (10.7 KB)

Custom Keyboard Maestro Plug-in

NAME

  • Choose filepath(s)

VERSION

  • 0.3
    • Adds custom prompt text

SYNOPSIS

  • Launches an OS X file chooser
  • Returns a list of Posix file paths

REQUIREMENTS

  • Yosemite
    • The core script chooseFiles.sh is mainly written in Javascript for Applications

OPTIONS

  • Dialog prompt
  • Folder at which dialog opens
    • Popup presets
      • Folder in Active Finder Window
      • Desktop
      • Home
      • Downloads
      • Music
      • Pictures
    • Custom path
      • (posix string or bash $Variable)
  • Multiple selections allowed (checkbox)
  • Output format
    • Unquoted lines
    • Single-quoted lines
    • JSON array string

CONTACT

Installation

To update an existing plug in action you must manually remove it from the

~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions

folder before re-installing it.

( The following Javascript for Applications code should be enough to update a plugin after any minor edits )

var	appKM = Application("Keyboard Maestro"),
	appEng = Application("Keyboard Maestro Engine");
		
appKM.reload();
appEng.reload();
5 Likes

When I choose more than one file, it saves all the selected filenames as a single clipboard entry. How can I break this clipboard entry down into its individual components.

Good question -

Once the action has captured a list of file paths into the clipboard (or a variable) you can use the standard For Each Item in a Collection action to step through the clipboard/variable text line by line, doing something with each individual line/filePath.

One file at a time.kmmacros (5.3 KB)

2 Likes

Thanks for this. I find it very useful.

Can this macro be edited to support selecting folders?

There's now a Choose Folder(s) version at:

Really nice!

Updated versions of this (0.3 above) and the Choose Folder(s) custom plugin

(enabling, in each case, a custom prompt text in the Choose dialog)