A keyboard shortcut to restore a set of Finder window tabs?

I haven't had Finder sidebar items disappearing lately, but yesterday my Finder window tabs all disappeared.

I was able to recreate them fairly quickly from items in the Finder sidebar. But wonder if there is a shortcut possible to do that.

Thanks?

My Finder sidebar items all disappeared recently too. I haven't investigated yet. But if it's both of us, then it's probably a recent change to macOS.

Another change that happened to me (at the same time?) is that if I type too slowly, a pop-up appears asking me if I want to use accented keys. I did google that one, and found that the solution was this command, which worked.

defaults write -g ApplePressAndHoldEnabled -bool true

Hi, @douglerner.

Do you have a fixed set of Finder tabs that you want to recreate, or are you wanting something that would track what tabs you have open and then reopen them if the window was closed? If the former, I have a suggestion to at least get you started...

I started a thread titled Finder Assistant. It's entire group of macros/subroutines. Within that group you will find a subroutine named: 𝗌.𝗳𝗻𝗱⇾NewTabOrWindowInSpace.

You could create a simple macro that makes multiple calls to that subroutine, one for each tab.

If you want to try that and need any assistance, please let me know.

1 Like

In his first sentence he says "his sidebar items disappear" and then in the same sentence he says "his Findbar window tabs disappeared." I know these are different things, but my suspicion is that both of these phrases are referring to the sidebar items. The reason I think that is because my sidebar items also disappeared a few days ago. Not my tabs.

In any case, your response was only about the "tabs." Do you have any advice regarding his first issue, the sidebar items?

It's basically a fixed set of Finder tabs. I'll check what you suggested. Thanks.

1 Like

I actually said I haven't had sidebar items disappear lately. So it was just about the Finder window tabs.

Sorry! I read your statement several times but I must have been blinded by the fact that my own sidebar items disappeared lately.

I believe this macro by @ccstone does exactly what you want:

This is nostalgic. Recalling Finder "sessions" was one of the main reasons I started using Keyboard Maestro to begin with, and looking for that macro/thread was one of my first ventures into this forum. Christopher mentions the macro is slow and perhaps that was the case on macOS Monterey, but it runs fast on my system (Sonoma, M1 Ultra): a set of 2 windows with 5 tabs each takes about 2.5 seconds to load.

1 Like

It does. I just tried it and it works. But I have a question about the needed folder settings.

image

If you are in a folder, how do you quickly grab the locations in the format shown? For example, Downloads on my Mac is in Macintosh HD > Users > admin > Downloads

image

Is there an easy way to grab the location in the format needed by the macro?

(This would make the second macro I've used in Keyboard Maestro so far.)

Thanks.

You have two options:

  1. Deselect any selected items while inside the folder OR go up one directory level and select the folder you want to copy the path of. Then click the Edit menu and, while holding ⌥, select the newly enabled Copy "Folder" as Pathname menu item (or, alternatively, use the keyboard shortcut ⌥⌘C);
  2. If your Path Bar is not visible, make it visible by selecting Show Path Bar from the View menu. Then right-click the folder you want to copy the path of and select Copy "Folder" as Pathname.
1 Like

I was trying this option. But the copied format is different from in the samples. Instead of ~/Documents, for example, it copies /Users/admin/Documents.

Does that matter?

In answer to my own question, while I don't know why it doesn't get copied as ~/Documents, /Users/admin/Documents works just as well. But I guess only for my system - ~/Documents is probably more general.

It seems to just add tabs to the current Finder window though. I wonder how to make it open a new Finder window with the specified tabs.

In Unix systems, tilde (~) can be used to specify the current user's home directory in paths. So ~/Documents, ~admin/Documents and /Users/admin/Documents are all equivalent paths. Since ~/Documents effectively means "the Documents directory located inside the current working user's home directory", this means that it works on my system, as well as yours, or anyone else's (assuming of course that a Documents directory exists inside that specific user's home directory). This is why Christopher chose to write those paths that way, so his macro works "out of the box" for most people, since most people will have those directories located inside their user's home directories.

You probably have a Finder window open with a tab that matches the first item on your path list, and that tab gets focused upon executing that macro. You will notice that if you close that tab, a new window will open instead. This is because of how the AppleScript that the macro runs works: if the first path in the FolderPathList variable (the first path on the list you edited to include your own paths) matches an existing Finder tab, the open item 1 of folderPathList line will bring that tab to focus instead of opening a new window. All subsequent items on the list are then opened as new tabs within that window.
If you change that line to make new Finder window to item 1 of folderPathList, this ensures a new window is always created first instead. Here is Christopher's macro with the revised code:

Open a Finder Tab Group v1.00 (Revised).kmmacros (7.5 KB)

and another approach, of course, is:

  1. Each listed folder opened in the traditional manner
  2. Finder > Window > Merge All Windows

Open list of folders in Finder tabs.kmmacros (3.4 KB)


Expand disclosure triangle to view JS source
const
    finder = Application("Finder"),
    fullPaths = kmvar.local_Folders
        .split("\n")
        .map(fp => $(fp.trim()).stringByStandardizingPath.js);

return (
    finder.activate(),
    finder.close(finder.windows),
    fullPaths.toReversed().forEach(
        fp => finder.open(Path(fp))
    ),
    fullPaths.join("\n")
);
1 Like

You can also drag'n'drop a file or folder from the Finder to a KM action's text field to insert the full path to the item, or drag in the proxy icon from the window's title bar.

You may need to pause a beat while over the text field so that it activates -- if you go bit fast you'll get a new "Open" action pointing to that location instead (possibly a quick tip in itself!). That action will have the path in the abbreviated form, so you could always deliberately add the action, drag'n'drop the abbreviated path from there to your variable, delete the action.

1 Like

Nice. One issue, though, is that Merge All Windows doesn't respect the sort order of the original list. Not sure what to do about that.

And I'm not sure I want the Finder to close all its windows to get my amalgamation. But that seems to be required for Merge All Windows.

Hi, @douglerner. Looks like you have a few options to consider.

Following up on my suggestion, if you download and install Finder Assistant as I suggested above, you can call the subroutine with the folder paths of interest. In the example below, a new Finder window will be opened and positioned (even if another Finder window is already open), and four tabs will be created.

The subroutine includes other features that you can read about in the header comment of the subroutine, not the macro below.

Download: Open New Window With 4 Tabs.kmmacros (3.2 KB)

Macro-Image


The only reason I didn't try that solution yet (I hope to) is because I'm such a complete KM novice and that solution looked overwhelming. :slight_smile:

In your new attachment (1) is that all that's needed to run it or is the complete Finder Assistant library needed and (2) is it easily modified to do more than 4 tabs?

Thanks.

Hi, @douglerner If you have another approach that is meeting you needs, the approach I'm suggesting might not be worth your trouble. But...

Technically you wouldn't need all of the subroutines included in Finder Assistant, but the simplest approach is to install them all.

In the post above, the example macro calls the Finder Assistant subroutine 𝗌.𝗳𝗻𝗱⇾NewTabOrWindowInSpace four times. That sub then calls other subroutines in Finder Assistant, but there's nothing you need to do if all of the Finder Assistant macros are installed.


If you look at the example calling macro above, I suspect you'll know how to revise it for your needs. But if not, feel free to ask. Or again, no offense whatsoever if you don't want to pursue this option.

1 Like

In for a penny... I installed Finder Assistant. It was quite easy with your instructions. I'm not sure what it all does :slight_smile: but it installed correctly.

Then I installed your Open New Window With 4 Tabs.kmacros, moved it into the Finder Assistant group and enabled that macro (all new terms to this novice). I tried it and the four example folders opened as you said, in a separate window.

So... I will play with this some more. Thank you!