Jump to content

RecentlyAdded — List directory contents by added date

Recommended Posts

@vitor Thanks for this wonderful workflow! Probably the one I use the most!


I was wondering if you had the intention of adding an exclusion list? I have my Keyboard Maestro settings file in this folder and as it updates almost every day it appears at the top of the results. Of course, I could and certainly will move this file somewhere else. But still wanted to ask you this question as I suspect other interesting use cases for this feature 😀

Link to comment
8 hours ago, politicus said:

Thanks for this wonderful workflow! Probably the one I use the most!


Thank you for the kind words.


8 hours ago, politicus said:

I was wondering if you had the intention of adding an exclusion list?


I do not. I doubt many people would use it.

Link to comment
  • 6 months later...

@vitor I would definitely echo @politicus statement about how awesome this workflow is! It's definitely near the top of my most used workflows.


Somewhat related to @politicus question about blacklisting items, is it possible to exclude temp/invisible items? I might be wrong, but the issue seems to be limited to Microsoft Word files. When I run your workflow, it always shows a handful of Word files that start with "~$". I notice them whether I run the workflow on my Downloads or Desktop folders, etc.


Thanks again for sharing the workflow!

Link to comment
  • 2 weeks later...
  • 4 months later...


On deleting cache file, also ask Spotlight to reindex directory. This should make certain operations (like renames) quicker to show up correctly.

To update, download the latest version (same URL) or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.

Link to comment
  • 6 months later...

Hi Vitor, 

I've made very good use of your workflow in conjunction with the Hook App. 

I have it index a folder with a bunch of files that point to all of my projects, and voila - instant project management tool!


I just need to figure out an option to list the files simply in alphabetical order and I'll be happy. 


If you're interested, here is the small post i made about using your worfkflow: https://discourse.hookproductivity.com/t/using-hook-files-to-maintain-a-list-of-current-projects/2884?u=seishonagon



Link to comment

@seishonagon No plans to officially add alphabetical sort. But you can make a new Script Filter with language set to /usr/bin/ruby and paste the following:


require 'json'
require 'pathname'

script_filter_items = Pathname.new(ENV['downloads_dir']).expand_path.children.sort.each_with_object([]) do |entry, array|
  name =
    if entry.directory?

    type: 'file',
    title: name,
    subtitle: entry,
    icon: { path: entry, type: 'fileicon' },
    arg: entry

puts({ items: script_filter_items }.to_json)


I offer that code, but no support for it (I tested it, and it worked).

Link to comment

Oh wow! Thanks!

That'll save me some mind numbing slog. To give you an example of my own script-fu, I've just spent 2 hours figuring out how to pass arguments properly to the "Run Script" action in Alfred Workflow ...


EDIT: for future reference (mine, specially) - don't forget to set "Argument Optional" in the script filter or the list of files won't appear


Edited by seishonagon
Link to comment
5 hours ago, seishonagon said:

To give you an example of my own script-fu, I've just spent 2 hours figuring out how to pass arguments properly to the "Run Script" action in Alfred Workflow

We’ve all been through it! The quintessential example is forgetting a semi-colon, though I doubt that particular example happens much with the checks we have today.

Link to comment

Major update! Your usage won’t change if you don’t want to.

First, I’ve done a big code cleanup.

Second, the list will now auto-refresh every few seconds, which is a great way to monitor for changes.

Third, I’ve revamped how the file list is cached (only applicable when sorting by added):

Previously, on every run it would read from the cache unless the directory had changed, in which case it would have to save a new cache. This means that if your directory changed quite often, you’d see little gain from caching.

Now, no caching is done by default. If you want caching, run :recentdownloadslaunchd which will install a launchd agent to watch your directory and save a new cache when the directory is modified. This means your cache will always be up to date and you’ll get the fastest run every time. This leverages technology built-in to macOS, there’s no weird hacks.

Fourth, I’ve worked around a pesky Spotlight bug when it sometimes returns (null) in a result, which is annoying if it gets saved to the cache because you wouldn’t be seeing the real path.

Finally, thanks to the above I removed the option to manually delete the cache.

To update, download the latest version (same URL) or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.

Link to comment
  • 3 months later...
  • vitor changed the title to RecentlyAdded — List directory contents by added date



Renamed this Workflow to RecentlyAdded. Removed the cache option, but in return the code is faster and smaller and it supports multiple directories at once.


Also removed the hardcoded ⌥↵ for Reveal in Finder. Anyone chan pick their preferred shortcut in Alfred Preferences → Advanced.

To update, download the latest version or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.

Edited by vitor
Link to comment
  • 3 months later...



I would like to have the same workflow but it could be nice if instead of search inside specific folders, i could have a search directly in the "recent" folder of the finder. 


Somebody does have the solution? 


Thanks for you help

CleanShot 2022-05-09 at 15.44.05@2x.png

Link to comment
1 hour ago, cpeneranda said:

search directly in the "recent" folder of the finder.


That is not a folder but a special view, you can’t search it directly.


There are other Workflows which aim to do what you seek. However, the results won’t be exactly what you see in the Finder’s Recents. I’ve looked into it in the past, and while you can massage mdfind (which uses the Spotlight metadata) to give you a semblance of the same results, it also shows a ton of junk you won’t be interested in (and thus have to be removed) and it leads to a conflict between showing too many results (which is slower) or too few. That’s why I never added the option to this Workflow; I always found it lacking in comparison.

But certainly you may disagree and find a Workflow which fits you well. Searching for “recent” on this Forum or GitHub should produce more results (here’s another).



Link to comment
  • 4 weeks later...

This one already used a single executable as the point of access, so it was a matter of replacing the Ruby script with the Swift binary (signed and notarised, source accompanying).


Any difficulties I bumped into had to do with getting used to the language and its processes; making it fit into the Workflow was dead simple, not really any different from a script. Especially because I wrote it in a terminal with nvim. I set the shebang and tested it by running—didn’t use Xcode or made a project, everything is a single text file.


Also didn’t bother creating a proper data structure for the output JSON and got by with serialising [String: Any]. I did start but making it generic was going to be a lot to codify all the possibilities of the output JSON, making it harder to read for no real benefit: the output JSON of a Script Filter is the whole point of it, so if it’s incorrect Alfred will let you know.


All in all, thumbs up.

Link to comment
  • 8 months later...

@vitor this has become one of my most used workflows and the speed of it is just incredible.


I'm using this with some paths on external volumes and it is just perfect. Would you ever consider adding the ability to define files types? I know there are some other workflows out there but the speed of yours is why i would love that addition.


No worries if it is a no, and thank you for all the killer work!



Edited by sepulchra
Link to comment

This is such a useful workflow. I've been looking for a replacement for Last changed Files. Whe I updated my OS, PHP was blocked and the workflow no longer worked, sadly. 


The biggest missing piece for me being able to use this workflow is the ability to include the contents of subfolders within directories. I frequently save files in various folders within my documents folder, and those are not visible in the current configuration. I there any way to open up the scope to allow for contents of folders within listed directories?


Many thanks!

Link to comment

Thank you both for the kind words!


It may help to understand my design goals for this specific workflow. As with @sepulchra, this is one of my most used and I tweaked it a lot to get to the current speed. The way I see it, the objective is to get as fast as possible into the contents a couple of directories and do some organising. E.g. It shows ~/Desktop and ~/Downloads, I open the most recent download—a zip which unpacks to the Desktop—then access the new thing on the Desktop to move somewhere else / change its name / grab a file from inside / … You can see why speed is crucial, I open it a bunch of times. And what’s important are the immediate children of the folders.


With that in mind, while those specific changes wouldn’t fit I do think you can get (closer to) what you want.


@sepulchra You can already kind of search for filetypes—but only one at a time—by typing the extension. E.g. if I type png scree I see all the Screenshot pngs on my Desktop.


@thisisb What you can do is add those frequent subdirectories to the directories Workflow Environment Variable. I will eventually turn that into a proper Alfred 5 File Picker configuration, before adding to the Gallery.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...