Dynamic Prompt from List based on Finder (or Pathfinder) list of Favorites in Sidebar

  • Prompt from List action: the advantages are obvious. The drawback IMO is that the list often has to constantly be updated.

  • Finder (or even better Pathfinder): I change the list of folders in the favorites multiple times a day, depending on what I am working on. It is therefore a dynamic list. Once again, the advantages are obvious but there is a drawback. In my case the list is long and it's tedious to localize a folder which slows down the workflow.

I would like to create a macro to overcome both of the above drawbacks: a dynamic prompt from list macro "in sync" ie changes as the favorites list changes.

Is it possible to create a prompt from list which would contain the favorites folders and dynamically keep up to date.

thanks in advance for your time and help

"Prompt From List" isn't limited to "hardcoded" lists -- you can also generate them at run time:

Prompt using RT List.kmmacros (4.0 KB)

Image

So all you have to do is get the things you want listed into a variable, one item per line, in a usable format. You can make a Collection from the contents of a folder, you can "For Each" that Collection to make a list, you can use that list in the "Prompt":

Prompt from Favourites.kmmacros (2.8 KB)

Image

thanks again very much.

Starting with the 2nd prompt from Favorites Macro

  • the ~/Library/Favorites only contains one file (no folders) dating back to 2016

  • I did some research to find the location of favorites and found this rather difficult to understand article

https://georgegarside.com/blog/macos/finder-sidebar-preferences-location/

Ah, gotcha... You want to use the Finder's "Sidebar Favourites" rather than the "Favourites" folder (which may be a hangover from an older OS version). Apologies.

To sound a note of caution -- this is almost certainly held in a plist somewhere, and plists often aren't updated in real time. Even if we can find and decode to give names and paths there might be considerable lag between you adding something and it available in the macro...

1 Like

Hey @ronald,

This is a tough nut.

It can probably be done with AppleScript UI-Scripting, but it's likely to be slow and clumsy.

This works to extract the name of items from the left-hand side-bar of Finder windows on my macOS 10.14.6 Mojave system:


tell application "System Events"
   tell application process "Finder"
      tell (first window whose subrole is "AXStandardWindow")
         tell splitter group 1
            tell scroll area 1
               tell outline 1
                  tell rows
                     set favoriteSidebarNames to value of static text of UI element 1
                  end tell
               end tell
            end tell
         end tell
      end tell
   end tell
end tell

set AppleScript's text item delimiters to linefeed

set favoriteSidebarNames to favoriteSidebarNames as text

It takes about six seconds to run and return a text-list in Script Debugger.

On a faster machine that time might go down, but it might not either.

And – this code may require some (or significant) adjustment to work with versions of macOS earlier or later then Mojave.

In my opinion you should roll your own favorites system with Keyboard Maestro.

  • You could keep everything completely in KM.
  • You could use a folder full of aliases in the Finder and work with that using KM native actions and/or AppleScript.

-Chris

very good idea thank you for your post and for the AppleScript

1 Like