This habit was inherited from windows 7. I normally choose all the files and then right click and get the folder size. But when I do this in Macos, mac open all the file info. Then how can I close those windows at once? Thank you very much.
To close all Finder windows at once, press the Option key while clicking the File menu in Finder and select Close All or just press Option-Command-W.
By the way, to get Summary Info for multiple files/folders in Finder, select the target files/folders and then Control click and select Get Summary Info. Then you only have one Get Info sheet open and you can press Command-W to close it.
tell application "Finder" set theWindowList to windows (* get all Finder windows *) repeat with i from 1 to number of items in theWindowList (* loop through them *) set shouldClose to false (* reset to false *) set this_item to item i of theWindowList (* get a window from the list *) set windowName to name of this_item (* get the window'ss name *) (* this list should contain class property that tells you the type of window - which is nice *) (* Class would be either "Finder window" for normal windows or "information window" for the Info windows *) (* However, it doesn't contain the class property. alas. *) (* So to differentiate, we can use the current view/panel props *) set thePropList to get properties of this_item (* in a try/catch as prop not set for the diff windows *) try set CurrentView to current panel of thePropList set shouldClose to true (* no error, it's an info panel, so close *) on error log "Not an info panel, leaving open: " & windowName end try (* this try/catch is just for a double check, feel free to comment out *) try set CurrentView to current view of thePropList on error if shouldClose = false then log "Not an info panel: " & windowName end try if windowName ends with " Info" and shouldClose then close this_item log "Closing info panel: " & windowName end if end repeat end tell