|
|
Two AppleScripts for unmounting, mounting local disk volumes
Updated for Mavericks: --begin script set alldisks to paragraphs of (do shell script ¬ "diskutil list|grep -v 'EFI EFI'|grep -v 'Recovery HD'|grep -o 'disk[0-9][a-z][0-9]*'") set all_non_boot_disks to paragraphs of (do shell script "df -hlg | awk -F/ '/disk*/ {print $5}'") set nonbootnumber to (count of alldisks) if (count of all_non_boot_disks) > 0 then try set all_non_boot_disks to items 2 thru nonbootnumber of alldisks on error set all_non_boot_disks to {} end try activate repeat with the_Item in alldisks try set the_ID to (do shell script "df -hlg | grep -m 1" & space & ¬ quoted form of the_Item & space & "| grep -o 'disk[0-9][a-z][0-9]*'") do shell script "diskutil unmount" & space & the_ID on error the error_message number the error_number if the error_message does not contain ":" then else if button returned of (display dialog "A disk couldn't be unmounted. Would you like to re-mount those already unmounted?" buttons ¬ {"Cancel", "Re-mount"} default button 2) is "Re-mount" then my mountAll(alldisks) end if end if end try end repeat else my mountAll(alldisks) end if on mountAll(alldisks) set actiondisks to {} repeat with i in alldisks if i is not in actiondisks then set actiondisks to actiondisks & i end if end repeat repeat with myitem in actiondisks try do shell script "diskutil mount" & space & myitem end try end repeat end mountAll --end script |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|