A Way to Eject All Disks

I want to eject all disks so I can grab my laptop and go. Surprisingly difficult (at least, I was surprised) but I found a way I wanted to share.

I know there's an AppleScript but as far as I can tell, it can eject a named disk but not eject all.

I found the excellent menu bar app, EjectBar ($2) and it works great but I can only activate it by clicking—it does not offer a hot key. I tried to create a KM macro but opening the EjectBar app does nothing and I do not know how to make it click the menu bar icon (which could be anywhere).

However, I also have Bartender and it allows a hotkey to trigger a menubar item, with modifier key if desired. That makes it easy because EjectBar ejects all if you trigger it with a right click.

Must be a better way, but this is what finally worked for me. This trick doesn't use KM but I'll bet I am not the only person looking here for a solution.

That's a shell script to eject a named volume. An AppleScript to eject all mounted disks (including shares) would be something like:

tell application "Finder"
	set theList to every disk whose ejectable is true
	repeat with eachItem in diskList
		eject eachItem
	end repeat
end tell

...although you'll probably want some error checking in there to deal with volumes that still have files open, etc.

1 Like

Hey Moe,

Please take the time to complain to the developer about this.

It amazes me that so many developers leave out basic usability functions from their apps...

-Chris

Is it not the case with the recent macoses (2023) that open files are automatically saved - at least text files…

… so we could use this AppleScript anyway?

/okn

Robert Boscacci on Medium wrote a zsh script:

gDrive_name="$(diskutil list | grep gDrive)"
gDrive_name=$gDrive_name[-7,-1]
BUP_name="$(diskutil list | grep BUP)"
BUP_name=$BUP_name[-7,-1]
diskutil eject $gDrive_name
diskutil eject $BUP_name

(his drives are called “gDrive” and “BUP”)

if this can be of help.

https://boscacci.medium.com/eject-all-disks-shortcut-for-macos-3c9ad7006cce
Paywall

/okn

The easiest way I know of to do this is with Raycast, which has an "Eject All Disks" command that can be assigned to a global hotkey, making it extremely quick and easy. I don't know exactly what it does under the hood but its works very well (and this command exists on the free version).

I use it to quickly eject my regular 6 mounted volumes from my laptop and it works great

Hey Folks :wave:

There is an Application - Developed by the same One Man show of company St. Clair Software - which is better known for Default Folder X.

It’s called Jettison and a very powerful automation friendly nifty little Application.

I‘m going to by this app for my self - have only tested it so far and this application is a game changer for handling external drives.

Edit:
I don’t even know why I haven’t bought it ten years ago when buying Default Folder X … such a waste of time ….:man_facepalming:

Greetings from Germany

Tobias

2 Likes

Thanks for the tip! I just downloaded this and it appears to fulfill a need I’ve had for awhile now but never bothered to look into.

Thanks Chris

A friend of mine demonstrated me this app a few days ago … I haven’t looked into what it really can do but I just grabbed the DMG file from his Mac right after his demonstration…

:joy::joy::joy:

I don’t know what happened that I was using my Macs without this tool … I mean … 10 Years …

Have fun :star_struck:

Uhmmm … by the way I now use all Applications from St Clair Software…. They are all worth buying …

Greetings from Germany

Tobias

For your interest - I’ve posted here about the AppleScript commands:

Greetings from Germany

Tobias

Hey Tobias,

Question about Jettison, if you are able to answer:
You know when you're trying to eject a disk (or unmount a volume) in Disk Utility and you get that message that it can't be unmounted, but you also don't get the Force Eject button? It just shows you the message and then you sit there, waiting for a few more seconds/minutes until it finally allows you to?

Do you know if Jettison forces any files/apps to stop using that disk?
Also, I don't always want to eject the whole disk, maybe just unmount a volume. Is this possible as well?

Thanks

Hello Tiago👋

If I remember it correctly Jettison has a String for Force eject and when that setting is enabled it gets this done when ejecting can’t be done like you described… but I have no clue about that… maybe you’ll need to consider talking to the developer to get more info about Jettison behaves to do it’s work with that setting enabled - and share the information with us …

The last hit of this can not eject disk error I got 3 Years ago (knocking on wood) …

For this you will have to use the mount and unmount solutions that are allready given to you from this community.

Jettison is all about automation for ejecting and mounting ejected drives so that you are able to unplug the drives in just a few seconds without getting the typical notification from Finder when unplugging a mounted device.

The thing with this application is that you will never ever need to do unnecessary things like unplugging your drives and plugging them back in for a drive to be mounted by the system when it was ejected before unless you have to because you maybe need the device to be taken with you.

I hope that I’ve got you covered … again I am this app for a few days and don’t have even got into all the details what this Application has to offer …

If you’ve read the other reply I linked to you maybe get it that I was not able to post about it’s AppleScript commands without the information from a friend of mine who was the person that got me into start using Jettison.

Greetings from Germany

Tobias

Thank you, I will get in touch with him.

I usually do that using Disk Utility. I just select the drive and choose Mount. Not sure if that's what you mean?