Convert list of file paths in clipboard to list of file names

Hello,
I am able to copy to the clipboard the list of all file paths (UNIX) in a folder via my file manager app (Forklift).
I would like to be able to filter the clipboard and end up with a list of file names.
thanks very much in advance for your time and help

Assuming your list consists of one pathname per line, and it is already in the clipboard, this macro shows how to obtain the list of file names. There are a number of ways to achieve this but I've used KM's Filter action to keep it simple. The result is saved in a variable called Local__Result and of course instead of displaying it as in this demo macro, you can do whatever you wish with it.

Download Macro(s): Test Filenames from Paths.kmmacros (6.6 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 10.15.7
  • Keyboard Maestro v10.2
3 Likes

your macro is a gem. Works perfectly which is not surprising considering that it comes from you. Thanks very much !

Beyond satisfying an immediate need, your macro is very instructive. How to read a file line by line using clipboard filter, how to append a variable to the results line by line etc.

I have been tying for a long time to figure out a way to create a personal KBM library of tips and tricks to solve specific problems. I tried creating a smart group of teaching macros, but it did not work. Neither did using favorites.

I need to create a list of issues (read a file line by line using clipboard filter, how to append a variable to the results line by line), find my problem in the list and somehow link me to the appropriate macro (your macro in this case) or rather set of instructive macros pertaining to that topic.

Would you have any idea ? Thanks VERY VERY much !

1 Like

Me too and I bet we’re not the only ones!

I know in my mind’s eye what I would like but I’ve never managed to create it.

Instead I rely on a number of macro groups in KM - with names like Library Macros, Subroutines, KM Cookbook, etc. They contain macros that are useful in a general sense such as: reading lines from a file; extracting specific data from text (numbers, dates, sentences, for example); getting metadata from web pages; downloading files; getting information about other macros… Many of these macros are fully documented in terms of their purpose, revision history, usage (inputs and outputs), algorithms/methods used, error responses, citations… said documentation living in a Comment action at the head of each macro.

What’s in my mind’s eye? A kind of (searchable) database with, for each item:

  • Brief title
  • Brief description/use case
  • Keywords
  • Item documentation (as above)
  • Image of item
  • File containing item (full macro or just one or more actions)
  • File containing test harness/example of usage

:pig2: :airplane:

I’ve looked at so many apps hoping I might use one and I’ve concluded that a wiki-type platform is probably the most suitable - you know something akin to KM’s own forum or its wiki. But I’m open to suggestion.

Has your thinking developed at all?

This is the kind of subject that would be best discussed in the outback lounge I think :thinking:

1 Like

It's a problem because it is also a question of discipline. Your outline is the ideal scenario and the problem in my case is continuity. The problem is that I lack the patience to stick to the plan long term.

For the moment, I do the following which was suggested to me by @jmtx before he passed away.

  • I add a keyword in the macro title, for example @teaching
  • at the top of the macro, I add a colored comment with the highlights of the macro in point form
  • I create a smart group for macro which contain @teaching in the title.

It is far from ideal, because you end up with a long list and how to search through that list.