How do I eject all USB memory sticks (or flash drives) that are under a certain size?
Model: MacBook Pro
AppleScript: 2.1.1
Browser: Google Chrome 5.0.307.9
Operating System: Mac OS X (10.6)
How do I eject all USB memory sticks (or flash drives) that are under a certain size?
Model: MacBook Pro
AppleScript: 2.1.1
Browser: Google Chrome 5.0.307.9
Operating System: Mac OS X (10.6)
Maybe something like this?
ejectDiskWithCapacitySmallerThen(200000) -- 200 GB
on ejectDiskWithCapacitySmallerThen(MB)
tell application "Finder" to eject (every disk whose capacity < (MB * 1024 * 1024))
end ejectDiskWithCapacitySmallerThen
I have three permanently mounted disks (really volumes) that I can distinguish from thumb drives by size, and this dismounts the others that are smaller than a limit that excludes the permanent drives:
set tLimit to 1.0E+11
tell application "Finder"
set V to list disks -- gives the names
set Caps to {}
repeat with oneDisk in V
if (capacity of disk oneDisk < tLimit) then
set end of Caps to {name, capacity} of disk oneDisk
end if
end repeat
end tell
-- then iterate through those
repeat with oneDev in Caps
set VName to item 1 of oneDev
set devName to do shell script "diskutil list | grep \"" & VName & "\" | awk '{print $6}'"
do shell script "diskutil unmount /dev/" & devName
end repeat
Thanks very much for that