AppleScript · Silent
Eject All Disks
Ejects every external drive, disk image and network volume before you unplug or pack up. Asks before it runs.
- Language
- AppleScript
- Output
- Silent
- Keyword
eject- Arguments
- None
- Confirmation
- Asks before running
- Timeout
- 60 s
- Licence
- MIT
- Author
- Docktopus
- File
- eject-all-disks.applescript (1.1 KB)
- Downloads
- 0
In Docktopus: Settings → Scripts → Browse Community Scripts. Read the source before you run any script.
Source
eject-all-disks.applescript · sha256 7152b2d56487…-- @docktopus.schemaVersion 1
-- @docktopus.title Eject All Disks
-- @docktopus.mode silent
-- @docktopus.icon eject
-- @docktopus.keyword eject
-- @docktopus.description Ejects every external drive, disk image and network volume before you unplug or pack up. Asks before it runs.
-- @docktopus.needsConfirmation true
-- @docktopus.timeout 60
-- @docktopus.author Docktopus
set ejected to {}
set failed to {}
tell application "Finder"
set diskNames to name of every disk whose ejectable is true
repeat with diskName in diskNames
try
eject disk diskName
set end of ejected to (diskName as text)
on error
set end of failed to (diskName as text)
end try
end repeat
end tell
if (count of ejected) is 0 and (count of failed) is 0 then return "No disks to eject."
set AppleScript's text item delimiters to ", "
set message to ""
if (count of ejected) > 0 then set message to "Ejected " & (ejected as text) & "."
if (count of failed) > 0 then set message to message & " Still in use: " & (failed as text) & "."
set AppleScript's text item delimiters to ""
return message