MACRO: Check/Eject Mounted Drives, v1.1


I just saw some recent activity in the A Way to Eject All Disks thread. That prompted me to spruce up my macro that has similar functionality. It has an option to spawn another macro that I've shared on the forum: Time Machine Assistant


Time Machine Assistant is not required.

Keyboard Maestro Export


Download: Check-Eject Mounted Drives.kmmacros (40 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 15.4 (24E248)
  • Keyboard Maestro v11.0.3

1 Like

Your fourth last action seems to be an unresolved Execute Macro action.

Hey, thanks for showing me that 1.5 is a valid duration for Display Large Text. I had no idea fractions were allowed.

1 Like

Hi, @Airy. It will be unresolved if you haven’t installed Time Machine Assistant. But now that you mentioned that, I think I'll add a comment with a link.

I'll upload v1.1 later this evening.

1 Like

I've updated the OP with Version 1.1 of Check/Eject Mounted Drives:

  • To address @Airy's comment, added a command above the Execute a Macro action.

  • Added a Display Progress during the eject process.

  • Added the e keyboard shortcut to select the [Eject] or [Eject All] buttons when not the default.

  • Saves and restores the foreground application. (During the eject AppleScript, the Finder is activated.)

I have a use case where I want to eject external directly connected drives but leave a network share (which the macro offers to eject along with the others) connected...essentially eject all but one named drive. Modified the Switch segment as shown below. The network share Volume Name is hardcoded. There's probably a better way of doing this but it works for me, except that the share is ejected even though it's not identified in the popup. And the large display says 3 were unmounted (not four). ??

Macro Segment Image

Popup

There's a "For Each" that appends names to the Local_drives variable -- the end result is what you are omitting your network volume from and what you see in the dialog.

But there's another "For Each" that does the ejection, and that's a new, different, list of mounted volumes:

A quick fix is to add an "is this a local volume" check to the AppleScript so you don't eject any network volumes. Try changing the lines:

tell application "Finder"
	try
		activate
		eject kmDrive
	end try
end tell

...to:

tell application "Finder"
   if local volume of disk kmDrive then
      try
         activate
         eject kmDrive
      end try
   end if
end tell
1 Like

Thanks. I don't understand why a list is built and then ignored, but I'm sure there is a good reason. Anyway, it turns out there's another "For Each" that monitors the ejection process, and yields

this result:

I can either ignore that or hardcode "Public" again, since there's no Applescript in that segment.
Appreciate your help.