Reopen Finder Windows Like You Can in a Web Browser?

I'm surprised this hasn't been asked before.

Has anyone come up with a solution for reopening, say, the last 10 recently closed windows? I'd map it to the same shortcut as Brave (cmd+shift+T). Hitting it once would open the most recently closed window; hitting it again would open the second most recently closed, and so on.

I can imagine one way to do this might be to have a macro triggered whenever the front Finder window closes, which add its path to a list. When the list entries number more than 10, the oldest one would be deleted. A separate macro (triggered by cmd+shift+T) would open the newest path on that list and then delete its entry.

Do you think I might be on the right track?


Dang, I didn't even know I needed this until now. I like that Safari reopens the last tab/window with ⇧⌘T but I didn't think about trying to replicate this for Finder. I like your method, I'm wondering if there's a way to do it with AppleScript...

1 Like

Not made much progress, but here's what I have so far:

- Finder Macros.kmmacros (75.1 KB)

Closed Windows - Save last path runs an Applescript that saves the path of the current window to a named clipboard before closing the window. Unfortunately, the script takes a moment and makes closing the window noticeably less snappy, so perhaps there's a better way of storing the path without delaying the window being closed...?

Closed Windows - Reopen opens a new finder window using the path stored in the named clipboard.

If I can figure out how to delete the most recent clipboard entry of a named clipboard, then reopening further windows will be possible. So far I haven't quite grasped how to do that. Any suggestions welcome!

That works pretty well though! And the lag is very minimal on my system; definitely something I can live with. I did however make some adjustments to it to use only variables.

Upon closing a Finder window the AppleScript saves the path to a tempClipboardvariable, and permClipboard variable is prepended with the tempClipboard variable.

Upon reopening the last folder (using the temp variable), the perm variable has the first line removed (the prepended portion from earlier) and then the next line down (which is now technically the first line, and the 2nd to last folder) is set to the temp variable for subsequent executions.

Try it out and let me know what you think. No doubt I could polish it some more... but so far it's working good for me.

Closed Windows - Save last path.kmmacros (22 KB)

Macro screenshot (click to expand/collapse)

Closed Windows - Reopen.kmmacros (22 KB)

Macro screenshot (click to expand/collapse)

Wow! Clever stuff!

Is there a limit to the number of lines that variable can contain or will it get longer and longer indefinitely, only removing entries if they are used to reopen a window?

Perhaps it doesn't bother you, but the lag when closing windows might be enough to stop me using this because it means I can't quickly close multiple windows by spamming cmd+w. If you think of an alternate way to trigger the save macro, let me know!

Thank you! Occasionally I have a moment of brilliance (generally followed by many moments of insanity haha).

Well I don't think there's any limit per se, and it will indeed only remove entries if they're reopened via the second macro. But I have a macro that deletes all my debug__ variables upon sleep anyway so there's no danger for me to have the variable fill up. Even if they did get really long it really doesn’t matter too much since that just means you'd have a really long list of windows you could reopen haha. But it's worth putting a disclaimer in if you were to publish it that was end-users knew that the variable has the potential to grow to large sizes if they don't use the restore macro often and/or do housecleaning.

I'll mull it over about the lag and let you know if I come up with anything!


I figured out a way to delete old entries with a definable maximum number, and added it to the Save macro.

I also thought of a way to eliminate the closing lag: the path of each front window is saved to a temporary variable whenever the front window changes. This is only passed on to the last closed window variable (I renamed them in my macros so I didn't get confused!) when you hit cmd+w. Passing on a variable is quicker than running a script, so it's noticeably quicker, at least for me.

- Finder Macros.kmmacros (114.6 KB)


I like it! I haven't had time to really dissect it but it looks quite nice. I ended up going a different route and recently made some adjustments to ensure duplicate entries were eliminated. In other words, if the last two windows you closed were the same folder, they won't appear twice in the master list.

Let me know what you think when you get a moment. :grin:

Reopen last saved Finder window.kmmacros (52.1 KB)

1 Like

Interesting! I ended up going a slightly different route for removing duplicates.

I also made it so that it only records the window path if it isn't already the most recent item on the list.


Anyway, here's my version. I'm pretty happy with it.

- Finder Macros.kmmacros (120.2 KB)

PS: What does this part do?


1 Like

Just something to throw into the mix: I was curious about this too. I'm always closing Finder Windows and having to navigate to them again to reopen them. And it got me looking at what already exists in Mac OS and whether it can be improved.

The Finder already keeps a list of all the recent windows it has opened. The list can be activated by right-clicking the Finder Dock icon. And the same list can be accessed at Finder>Go>Recent Folders. At the bottom of the list is an item "Clear Menu" to start again. It's a pain to use because of having to navigate through the menus - but of course there's an automation App that's good at that sort of thing... :rofl:

And it's probably possible (I haven't tried it yet) to make a custom smart search folder that lists only Folders and by date opened. Just mentioning this as a part of what you are doing is making the list and the Mac seems to making this list already.

1 Like

I started out trying to use the Go > Recent Folders menu item, but that list isn't maintained in a purely chronological manner. I tried the Smart Folder approach, but the trouble with it is that it only logs recently opened folders if you actually open them. If you navigate to them, the directory you end up in doesn't get logged. I suspect you're right to think there's mileage in leveraging Finder's history, but I can't think how.

I presume one of you guys posted this over at Stack Exchange...? Be interesting to see if any Applescript ninjas offer up a neat and tidy solution...

1 Like

I attempted to build something using this menu but it’s in reverse chronological order meaning the most recently closed window is at the bottom of the list (which makes no sense to me), so having AppleScript trigger a su menu item that could be numbered anywhere from 1 to 10 was giving me lots of troubles.

Man that's a good idea! I'm enjoying comparing notes on this because it goes to show that there are often many effective ways to accomplish something!

When there were no more lines in the perm variable, it was not making any changes (IE replacing) the first line of the temp variable which meant that the very last folder path was on there all the time. So now if the perm variable is empty then it also empties the temp variable.

Although less invisible than using AS, selecting the last item in the list isn't that hard using actions. You just select the Clear Menu item, hit the up arrow and then enter. The problem is the list isn't maintained in chronological order if there are duplicate items. For example, if I open folders A, B, C, D and then open folder B again, the list remains A, B, C, D rather than A, B, C, D, B. This makes it entirely unusable for this purpose, as far as I can tell.

I wonder if AS has a term for last closed window? That would simplify things a little, but we'd still need to maintain the list in chronological order. Between us, I think we've come up with a reliable solution, but of course I'm still curious to know if it could be condensed, particularly as my own method involves three macros for this simple task.

I wonder if @ccstone has any thoughts on it?

1 Like

All good points, and I'm not aware of any AS term for that. But yea I'm pretty happy with our solutions and I imagine you, like myself, will be tinkering with it for some time still :laughing:


Actually the list is in alphabetical order (on my System anyway). So, not useful for what you are doing in opening most recent first but useful in its own way. And it is better than the Smart Folder as it logs every Finder Window and doesn't seem to miss any. For Finder>Go>Recent Folders to work the Mac must be saving a list somewhere...

1 Like

Good point… hmmm… I wonder if a google search would tell me where that list is and if it would be accessible to KM. I guess I know what I’ll be tinkering with this afternoon :sweat_smile:

1 Like

For the sake of completeness, there is alos one deficiency in the method of logging the closed windows. If you close the window using the mouse, it isn't logged. Again, I wonder if there's an AS solution for that?

Instead of using ⌘W as the trigger, perhaps you could use "the focused window's title changes". This seems to grab the path to the front Finder Window each time a Window is opened or closed, and could be used to build your dynamic list.

The trouble with that is that the result it returns isn't the path of the window you just closed, but the one that the focus switches to afterwards.

I am in fact using the focused window title change trigger to log the window paths, but as a separate macro (in order to avoid lag when actually closing the window). These paths are then only saved to the list after you close a window (using cmd+w).