You can enumerate the open windows and tabs using dbus
; going straight for tabs:
dbus-send --session --dest="org.gnome.Terminal" --print-reply /org/gnome/Terminal org.freedesktop.DBus.ObjectManager.GetManagedObjects | grep -c /screen/
will tell you how many are open.
If your shell cooperates with VTE, GNOME Terminal will knows about the last current directory for each running shell in your tab (not the current directory of the leaf process running in each tab, if it’s not the shell); but I don’t think there’s a way to retrieve that over the bus.
What you can do is list the current working directories of all the “leaf” processes whose parent is GNOME Terminal:
pstree -T -p $(pgrep gnome-terminal) |
sed -E 'sX^.*\(([0-9]+)\)$X/proc/\1/cwdX' |
xargs readlink -f
This won’t tell you which tab is where but I’m not sure that’s significant (as far as I can tell, there’s no way to determine what each tab is running). You can use variations of this to find out what is running too, not just the current working directories.