Put Away Workspace

I create a lot of macros that open up files and folders and arrange them into a workspace for working on different projects.

I am looking for a way to "put the workspace away" when I am done.

Example: Macro for working on budget:

  • opens a new Finder window, put it on my main monitor left side
  • opens three Finder tabs of folders: budget 2023, invoices 2023, quotes 2023
  • opens a Numbers spreadsheet: Budget 2023 on the secondary monitor
  • opens Microsoft Remote Desktop
  • opens a FileMaker database file on the secondary monitor
  • opens a new Chrome window with three browser tabs
  • opens a new Safari window with one tab

When I am done working on the budget, I would like to close all of the above windows (but not necessarily other apps or windows in the browsers)

What's the easiest way to do this?

Assuming all the Windows you want to close have fixed names you can use a Keyboard Maestro Action to close specific Windows and possibly AppleScript is the way to go to close specific Tabs. If you don't want any windows of an App to be open you can use Keyboard Maestro to quit that App (or possibly use an AppleScript to close every window of that App).

It looks like each item in your bulleted list might need a slightly different approach...

Here are some examples:

And here are the AppleScripts to make them easier to copy:

tell application "Numbers"
  close (every window whose name starts with "Budget 2023")
end tell

tell application "Safari"
  tell front window
    close (tabs whose name starts with "Google")
  end tell
end tell

tell application "Notes"
  close every window
End tell