The following procedure can be followed to add a shortcut icon to a Finder toolbar:
Open the Shortcuts app and select a shortcut.
Add the shortcut to the Dock by way of the File or context menu. This will create a shortcut app in the user’s home Applications folder and will add the shortcut to Launchpad.
Optionally, change the icon of the shortcut app and move it to another folder to remove it from Launchpad.
Command drag the shortcut app to the Finder toolbar.
Remove the shortcut from the Dock if desired.
The most likely use of a Finder shortcut icon is to perform actions on selected files. The following shortcut–which merges selected files in a PDF–can be used for testing:
The following shortcut selects all files and packages in a Finder window that have the same extension as a currently-selected file or package. I wanted this to also work with a currently-selected folder, but, for various reasons, that was not possible.
BTW, every time you run this shortcut in a particular folder, a privacy dialog appears. Permission to access this folder is remembered, but this is still a major annoyance. I researched this issue but couldn’t find a solution.
I wanted to run a few shortcuts by way of Finder toolbar icons, and they needed to get the folder that is the target of the front Finder window. There’s not an action that does this directly, and I used an AppleScript action instead. The following is a simple example:
As much on a proof-of-concept basis as for actual use, I wrote two shortcuts that are run by way of icons in the Finder toolbar. The first uses GUI scripting to select the Go > Enclosing Folder menu item. There are some significant restrictions on the use of GUI scripting in shortcuts, but simple stuff like this seems to work well.
The second shortcut places on the clipboard the path to a selected item or to the target of the front Finder window. The user can specify a POSIX or HPFS path format. The native shortcut dialogs cannot have three buttons, and this shortcut uses the free swiftDialog app instead. The following screenshot only shows a portion of the shortcut.
In the Privacy & Security section of System Settings, I have set permissions in both Accessibility and Full Disk Access for Shortcuts, Shortcuts Events, ShortcutsActions, and System Events. I also had to separately give Accessibility permission to the Enclosing Folder shortcut.
The following shortcut empties the trash, and it works exactly as I want. However, I’d prefer not to use the Run AppleScript actions, but I haven’t found an alternative. Gemini AI says this can be done with a Delete Files action, but I don’t see how this can be made to work on my Sequoia computer. Does anyone know how to do this without the Run AppleScript actions? Thanks!