Unplugging external drives when using MacBook docked

I’m wondering how people manage using external hard drives with Macbooks used with external displays (docked). I know a lot of people on here are using MacBooks Pro docked to the Studio Display via a single TB cable. Do you have to individually eject any and all external drives before unplugging? Are there any hacks to make this easier / less janky? Thanks in advance!

Alfred has a nice ‘Eject all’ command which takes care of this for me. See https://www.alfredapp.com.

5 Likes

I’ve just been ejecting manually, so thanks for this tip! Yet another reason why I should try Alfred apparently

1 Like

I wrote a very simple AppleScript for this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

(* This script upmounts the named drives*)


tell application "Finder"
	activate
	if (disk "YourDiskName1" exists) then
		eject "YourDiskName1"
	end if
	
	if (disk "YourDiskName2" exists) then
		eject "YourDiskName2"
	end if

end tell

Change the “YourDiskNameN” to the names of the disks you want to eject. And add additional “if” clauses if you have more disks.

As I am by no means an AppleScript guru I suspect there is a more elegant way than my brutal force method of explicitly naming each drive. I’m sure you could get list of mounted drives and loop through that list. But this worked for me when I needed to do this.

1 Like

I have a button on my stream deck that triggers km with apple script to eject all my drives, shut a few apps (including the stream deck one) so I can just unplug my tb4 cable.

1 Like

I believe all launchers have this feature. Raycast has it for instance.

2 Likes

The Jettison app by the same guys who do Default Folder X is another option.

4 Likes

Ooh, that’s a good tip. I found an Applescript to eject all drives and it runs reeeeeeeeealllllllyyyyyy sllooooooooowwwwwlllly compared to Alfred’s “Eject all”.

The trouble I have with Alfred’s tool is lately I don’t seem to get the notifications of the ejects so I don’t know when it’s done without checking.

What I really want is a script that can return the (actual) external drives currently mounted, so I could incorporate that into a BetterTouchTool TouchBar widget. I’ve looked at system tools but it’s a bit messy, it seems.

1 Like

Thanks all for the suggestions, and sorry for late reply. I will certainly give some of them a go. Alfred sounds good for my level of expertise.

I ended up trying again to find a good way to do it and figured out a BetterTouchTool widget which I now run on my TouchBar (sorry to make all TouchBar opponents jealous).