Automatic Ejecting of External Drives

Bash scripting is rather easy, even on a Mac (though a little different from Linux). The biggest parts are that you can stack commands in the command line with the semicolon and the unmount command is diskutil unmount /Volumes/<name_of_drive_1>; diskutil unmount /Volumes/<name_of_drive_2>.

You can change unmount to eject to fully remove the drive from the system. Unmount is nice as it allows you to remount the drive without having to unplug and replug the drive. However, if you are going to unplug it anyways, just use eject. I linked to some resources below.

General unmounting:

Making a bash script on Mac:

Making a nice pop-up notice when done:

Warning: Bash scripting and automation is easy, fun, and rewarding. You may just find that you start doing a lot of things with it and are sucked into the blackhole that is automation. Just wait until you start putting them in cron. Also if you do start making a bunch, get a Github/GitLab account and save them; makes it easier to move to another machine.

1 Like