I have written and tested a Zsh script that takes two parent folders as arguments and then opens a Finder window with the common first-level folder names as new tabs. This has been tested on macOS 11.6.8 and 12.5, both as a script run in the Terminal application, and as an Automator application. I have not done this in a Monterey Shortcut due to time available.
Because of Big Sur and Monterey security issues, one will initially be greeted with two dialogs during the first Automator run:
- Automator wants access to control "System Events"
- Automator wants access to control "Finder"


In each case, when you click OK, an entry will be placed in System Preferences > Security & Privacy > Privacy > Automation for you and that dispenses with future Automator security challenges.
Here is a tested Automator application with just two actions. In the Ask For Finder Items, you choose the first folder, press the ⌘ key, and then choose the second folder. The next thing you will see is a Finder window with tabs bearing the folder names in the second folder.
When you drag and drop the Utilities Library > Run Shell Script, it will present some loop text when you select Pass input: as arguments. You remove that boilerplate and then copy/paste the following code into that Run Shell Script window:
#!/bin/zsh
: <<"COMMENT"
Provide two parent folders whose where their first level folder names may match. Open Finder tabs
for each matching folder in the second parent folder.
Dependency: Does not care if the Finder Preference > General is set to open in tabs or not
The System Events in the AppleScript function requires security privileges set in:
System Preferences > Security & Privacy > Privacy > Automation > Terminal > √ System Events
Usage: scriptname.zsh Parent_Folder_1 Parent_Folder_2
Reference: https://discussions.apple.com/thread/254102537
Tested: macOS 11.6.8, 12.5
Version: 1.0
Zsh modifiers: a absolute path
s substitution
N Null glob prevents script from bombing if files are missing
/ strictly folders
on sort ascending on filename
t ordinarily the filename.ext or just foldername without path
U in arrays, it forces uniqueness (no duplicates)
Author: VikingOSX, 2022-08-10, Apple Support Communities, No warranties expressed or implied.
COMMENT
# initialize arrays
typeset -ga f1=() f2=() common=() preface=()
# the two main folders are provided as arguments to the script and made absolute paths
# can use tilde paths or just plain folder names if in the current directory
FOLDER_1="${1:a:s/\~\//}"
FOLDER_2="${2:a:s/\~\//}"
function new_finder_tab () {
/usr/bin/osascript 1> /dev/null <<AS
use scripting additions
tell application "Finder"
set fullpath to POSIX file "${1}"
tell application "System Events" to tell process "Finder"
set frontmost to true
-- new Finder window tab
keystroke "t" using command down
end tell
-- the folder to be assigned to the new tab
set the target of front Finder window to fullpath
-- set toolbar visible of front Finder window to true
-- set pathbar visible of front Finder window to true
end tell
AS
}
# arrays of alpha sorted sub-folder names found in respective first level folders
f1=( ${FOLDER_1}/*(N/on:t) )
f2=( ${FOLDER_2}/*(N/on:t) )
# perform array intersection to discover unique (u) common folder names
common=( ${(u)${f1:*f2}} )
# prepend the FOLDER_2 path to every array element
preface=( ${FOLDER_2}/$^common )
# just loop and open new Finder window tabs with every matching folder name
for f in ${preface};
do
new_finder_tab "${f}"
done
# clean up
unset f1 f2 common preface
exit 0
The finished Automator application looks like the following:
