Show Open Recent Files List

Thanks for sharing.

As you noted, not with the native KM Prompt.
But it will if you use MACRO: Spotlight Search Prompt by @DanThomas.

I have made some small mods to your script, and then used the results in the SSP:

@sims Script with My Mods

# $time.now(-$KMVAR_Local__TimeBack) does NOT work.
# So, must set time back directly for now.

mdfind -onlyin "$KMVAR_Local__SearchFolder" '(kMDItemFSContentChangeDate > $time.now(-24h))' \
| tr '\n' '\0' \
| xargs -0 -n1 stat -f "%m %Sm %N" \
| sort -rn \
| cut -d ' ' -f2-4,6-

I added two KM Variables to make it easier for each user to customize. Unfortunately, the $time.now does not work with Local__TimeBack. So, for now, we have to set the time directly in the script.

Here's my macro which uses this script with the SSP:

MACRO:   Get Recent File List [Example]

--- VER: 1.0    2018-05-15 ---

DOWNLOAD:

Get Recent File List [Example].kmmacros (9.5 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

This macro requires the use of this sub-macro, which you must download separately:
MACRO: Spotlight Search Prompt


image


Known Issues:

  1. $time.now(-$KMVAR_Local__TimeBack) does NOT work.
    • so the time back is set manually for now.
  2. Too many unwanted results of mdfind search
    • When I ran it using my Home folder (~), it picked up lots of files in the ~/Library folder that I don't want to see, and also lots of files used by Outlook 2011 in my ~/Documents folder
    • So, we need a way to exclude selected folders
  3. SSP Prompt shows entire file path, which makes the list hard to read, and causes some file names to not be visible.
    • It is possible with SSP to just show the file name, display full path in status line, and return full path.
    • To do this we need to return the list from the Shell Script as a JSON string with these fields.

If anyone knows how to fix any of these issues, please post below.

1 Like

Reviving an open question in an old topic:

Is this what the recent change to Prompt With List, keeping track of the modifier keys, accomplishes? Has anyone used that feature in a situation like this?

This Alfred Workflow is brilliant.

Tap rr to list files opened recently by the foremost app.
Tap rf to list recent folders.
Tap rd to list recent files.
Tap ra to list apps opened recently.

1 Like

Thanks, @noisneil!

Recent Items is another powerful workflow with overlapping features.

1 Like

Is that workflow still working for you? I seem to be able to call up recent folders no problem but everything else seems broken for me.

1 Like

Hi, @noisneil. The Alfred workflow Recent Items mostly continues to work as expected. I've never been able to set a Favorite using the ⌃+<return> method. However, I am able to add them using the Universal Actions. But since ⌃+<return> is not working, I don't know how to delete an item from the Favorites.

I'm using...

Sonoma 14.4.1 (23E224)/MacBookPro18,2

If you have Setapp you could use a program name Trickster. Apparent Software has shared two accompanying Alfred workflows. I installed them, but my muscle memory still has me typing rec.

1 Like

I've been using Default Folder's Recent Folders and Files tracking for this and using AppleScript to bring it into Keyboard Maestro.

tell application "Default Folder X"
ShowMenu "Recent Files"
end tell

tell application "Default Folder X"
ShowMenu "Recent Folders"
end tell

And you can cull a list of favorites to display as well:

tell application "Default Folder X"
ShowMenu "Favorites"
end tell

2 Likes

Can it restrict the results to files associated with the front app?

Not directly, as far as I can tell.

Files shown are attempted to be restricted to ones the app can open and I'm unsure that provides what you are looking for.

There are options to restrict what folders are available to apps and what folders are shown as defaults for an app. IDK if restricting apps to particular folder sets restricts which files are shown in recent files list or if their culled regardless of folder available to an app with the restriction of file types the app handles.

There's an option to run terminal commands from within the app when dealing with directories and I'm a noob with Unix so I don't know if that could be used.

Below are some sections from the manual that might be useful and I'll ask the question of restricting the recent file results to a per app basis if you like.

When you're using a file dialog, Default Folder X shows only the files that the current
application claims it can open. Note that this isn't always correct : some applications
claim to open files that they can't. If an application can't open a file you've selected,
Default Folder X will switch the file dialog to the folder containing that file, but it won't
select it and open it.

Folder Set: This menu allows you to create, select and manage "folder sets". A folder
set is Default Folder X's way of grouping your default, favorite, and recently used
folders for you. You can switch between folder sets at any time to help manage your
work. You can, for example, keep one list of Favorite folders for use when you work on
your latest novel, while using another set of Favorites when you're managing your web
site. Just set up multiple folder sets and add the folders you want to each of them.
Then, when you want to switch between them, select the appropriate one in Default
Folder X's settings, in the Default Folder X toolbar within Open and Save dialogs, or
from the Default Folder X menu in the menu bar.

Tab Favorites: Default Folder makes your favorite folders accessible from Open and
Save dialogs, and also allows you to attach keyboard shortcuts to them to immediately
jump to particular Favorites that you use frequently. To set a keyboard shortcut, just
click on the shortcut text next to the folder name.

Tab Default Folders: Default Folder X lets you set up a default folder for applications
or types of files. Every time you launch an application, Default Folder X will make
certain that the first file dialog you see when you choose Open or Save shows the
contents of that application's default folder or folders. If "when" is set to "once", Default
Folder X will let the application do as it wishes for subsequent Open or Save dialogs,
because the application should know what is most logical for its purposes once you've
started in your default folder. If you set "When" to "always", Default Folder X will switch
the file dialog to your default folder every time you open or save.
If you notice that you often use files from the same location, add that location to the
Default Folders tab by doing the following:

  1. Open Default Folder X's settings and select the Folder pane
  2. Select the Default Folder tab
  3. Click on the ‘+’ button located at the bottom left of the settings panel
  4. Select the desired folder from the Finder's sidebar or the file list box
  5. Click on the Add Folder button
  6. Click on the ‘All Applications’ text for that folder to select a specific application. If the
    application does not appear in the list of running application at the top of the pop-up
    menu, choose Other... to select it, then press the OK button
    For Save dialogs, you can also set a default folder for a particular file type (such as all
    JPG image files). Just click in the Extension column of the folder list to change which
    files a default folder applies to.

Open a menu item in Terminal by (Control/Option/Command) clicking: If you are a
macOS power user that types Unix commands in the Terminal to get to the nuts and
bolts of macOS, this option can be very useful. This feature causes Default Folder X to
execute the "cd" command in a Terminal window when you choose a folder from the
Favorite or Recent menu while holding down the appropriate key. If you just saved
something in a Save dialog and now want to run some Unix commands in that
directory, this is an easy shortcut to get there.

1 Like