2 problems selecting and opening file

I wrote a macro to select a file and open it.

The macro consists of only 2 actions and both are wrong !

1- prompt for file. Instead of all the files in the folder, I would like to select from only those files which contain KBM in the title. What should I write in the title field ? I tried just writing KBM as if the field meant 'title contains' but I still end up with a listing of all files in the folder.

2- open file: if I pick a file in the prompt for file action and send it to a variable, I am unable to open that file using the variable name

thanks in advance for your time and help

  1. As the KM wiki entry for Prompt for File says, the Title field is for setting a title for the prompt. As far as I know, there is no way to filter files by words contained in their name with this action, though you could conceivably make your own file prompt with Prompt with List and For Each like so:

Example Macro.kmmacros (3.8 KB)

  1. Pretty sure you've got a space in front of %Variable%ScrKBM%, which would invalidate any file path the variable contains.
1 Like

The "Title" field is NOT a search field. It is just for information that is displayed with the Prompt is shown.

One good solution is to use an AppleScript to build a special file list that is:
POSIXpath__FileName

and use this list in a KM Prompt with List.
Use of the two underscores causes only the text to the right to be displayed, but the text to the left is the actual data that is returned.

The script returns ALL files in the Target Folder, but you can easily filter the list by typing any characters in the file name.

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Example Output

image

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Choose File in Finder Window Using KM Prompt With List [Example]

-~~~ VER: TBD    DATE_TBD ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Choose File in Finder Window Using KM Prompt With List [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Choose File in Finder Window Using KM Prompt With List

HOW TO USE

  1. Open Finder and select any item in the Target Window
  2. Trigger this macro
  3. AppleScript Builds List of all Files in Target Window, using the format:
    • POSIXpath_FileName
  4. The KM Prompt with LIst then uses that list
    • Only the File Name is Displayed
    • The File Path is returned for the selected item.

NOTICE: This macro/script is just an Example

  • It is provided only for educational purposes, and may not be suitable for any specific purpose.
  • It has had very limited testing.
  • You need to test further before using in a production environment.
  • It does not have extensive error checking/handling.
  • It may not be complete. It is provided as an example to show you one approach to solving a problem.

REQUIRES:

  1. KM 8.0.2+
  • But it can be written in KM 7.3.1+
  • It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
    .
  1. macOS 10.11.6 (El Capitan)
  • KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. :wink:
      .
  • Assign a Trigger to this maro.
  • Move this macro to a Macro Group that is only Active when you need this Macro.
  • ENABLE this Macro.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    • ALL Actions that are shown in the magenta color

USE AT YOUR OWN RISK

  • While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

1 Like

Wow !!

a superb macro. I like the fact that the search function is independent of the order of the words in the filename

1- choose file from folder selected in Finder: very useful macro ! I would prefer Pathfinder to Finder. I tried changing Finder to Pathfinder in the script but it did not work.

2- I would like to create multiple variants of the script, each with a fixed folder (not the one selected in PF or Finder). How would I modify the script to achieve that ?

thanks very much !!

thank you very much. I am having some difficulty understanding the macro. Am working on it.

so I solved my problem by simply adding the following action before the script. I don't need that change Finder to Pathfinder and I don't need to modify the script to make it folder specific.

so all is fine. Thanks very much !

and I am able to limit the search simply by adding a search term in the default field of prompt with List.

so I am very happy thanks to your macro !

Well done! :+1:

I'm very pleased that you were able to mod my macro to best suit your needs.

Looks like you have all you need, but FYI I just posted a more full-featured version of this macro:

MACRO: Choose File From All Files in Target Folder using KM Prompt With List [Example]

It will use whichever is frontmost, Finder or PF, OR can use a preset Target Folder path.
It also will allow you to change Target Folder after you are in the list.

2 Likes

the macro is an absolute gem. I use it many times a day.
I am curious as to why there is a significant delay before the dialog box appears and if there is anything I can do about it.
thanks very much

If you are referring to the macro immeditely above your post, MACRO: Choose File From All Files in Target Folder using KM Prompt With List [Example], I just tested it again and it works very fast for me.

If you are referring to a macro that you have made changes to, then you will need to upload the macro.

1 Like

I am using your macro. No changes expect for specifying directory which is part of the configuration