How to close all windows of MacOS Finder EXCEPT the foreground window The number of times I want to drop something from the Finder to another application but I'm stopped by endless open windows below. I have never found a simple shortcut to close them all except for the active one. 

Could this be scripted?
As far as I can see there isn't a keyboard short-cut to hide all windows except the foreground window. macOS hides applications not individual windows of an application (and the Finder is just an app).

What you can do is Option-TAB to your target application after grabbing the item in the Finder. Basically once you "grab" a file, don't let go of it, but rather, use the application switcher (invoked by Option-TAB) to swap to the application you want to drop the file into.

Once the app is highlighted in the app switcher, release the Option and TAB keys, which will bring your app and it's windows forward, then you can drop the file on your target window.

I made a quick GIF to show this in action: