Ejecting all network drives via Applescript/Automator/Shell?
Solution 1:
I use Automator. I inserted 'Get Specified Finder Items', and named the target disks that I wanted to 'Get'. Only those named get chosen, but network drives do work. I then pipe this to 'Eject Disk'.
That's it.
Solution 2:
Easily done by using the -t
option of the umount
command. From the man page which you can read using man umount
:
-t type
Is used to indicate the actions should only be taken on filesys-
tems of the specified type. More than one type may be specified
in a comma separated list. The list of filesystem types can be
prefixed with ``no'' to specify the filesystem types for which
action should not be taken. For example, the umount command:
umount -a -t nfs,hfs
So,
do shell script "/sbin/umount -a -t nfs,smbfs"
should umount all NFS and Windows/Samba shares mounted.
EDIT: You may also want to use the -f
option to force the action. Read the man page for details.
EDIT2: Apologies, umount isn't behaving as advertised, at least on my Snow Leopard. So I'd do it like this remembering to change msdos
to your desired filesystem type:
set mounts to {}
set mounts to paragraphs of (do shell script "mount | grep msdos | cut -d ' ' -f3")
# Umount non busy filesystems
repeat with mount in mounts
set pid to (do shell script "fuser -c " & mount)
if pid is equal to "" then
# We use diskutil since classic unix umount cmd needs sudo/password
do shell script "diskutil umount " & mount
end if
end repeat
HTH