Skip to content

deverman/eject_all_disks_shortcut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฝ Eject All Disks โ€“ macOS Shortcut

A macOS Shortcut that ejects all connected external disks using a shell script and diskutil. I liketo put this one on my Stream Deck

๐Ÿ›  How It Works

This shortcut uses the built-in Run Shell Script action in the Shortcuts app to detect and eject all mounted external disks.

Shell Script Used

IFS=$'\n'
disks=$(diskutil list external | grep -o -E '/dev/disk[0-9]*')
for disk in $disks; do
  diskutil unmountDisk $disk
done
  • diskutil list external โ€” lists all connected external disks.
  • grep filters the output to extract only the disk identifiers (e.g., /dev/disk4).
  • Each disk is safely unmounted using diskutil unmountDisk.

๐Ÿš€ Installation

  1. Open the Shortcuts app.
  2. Create a new shortcut and add a Run Shell Script action.
  3. Paste the script above into the action.
  4. Optionally:
  • Set the shell to bash
  • Set input to โ€œNoneโ€
  • Set โ€œPass Inputโ€ to โ€œto stdinโ€
  1. Name your shortcut something like Eject All Disks.
  2. (Optional) Add it to your menu bar or assign a keyboard shortcut for quick access

โš ๏ธ Notes

  • You may be prompted to give the Shortcuts app or Terminal full disk access or permissions to control your Mac.
  • This shortcut only affects external disks. Internal drives are unaffected.

๐Ÿ“Ž License

This project is released under the MIT License.

About

A macOS Shortcut that ejects all connected external disks using a shell script and diskutil

Topics

Resources

License

Stars

Watchers

Forks