Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Mount and unmount external drives easily via AppleScript ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Mount and unmount external drives easily via AppleScript
Authored by: MacTipster on Jun 02, '13 01:41:46PM

I have tried the following script in AppleScript Editor.app on Mac with OS X 10.8.3 (Mountain Lion) and it does unmount PenDrives, but not the internal iMac disks when booting from an external SSD, which is what I want:

-----------------------------------------
set diskName to "Macintosh HD"
tell application "Finder"
if disk diskName exists then
eject disk diskName
else
tell current application
set deviceLine to (do shell script "diskutil list | grep \"" & diskName & "\" | awk '{ print $NF }'")
if deviceLine = "" then
display dialog "The disk \"" & diskName & "\" cannot be found." buttons {"OK"} default button 1 with title "Error" with icon caution
end if
set foundDisks to paragraphs of deviceLine
repeat with i from 1 to number of items in foundDisks
set this_item to item i of foundDisks
if this_item contains "disk" then
do shell script "diskutil mountDisk /dev/" & this_item
end if
end repeat
end tell
end if
end tell
-----------------------------------------

How to fix it?
Thanks.



[ Reply to This | # ]