My iMac usually has 4 to 6 external hard drives attached but unmounted (so that a bunch of drives don't have to wake up each time some app puts up an open and save dialog). Every time I need to access one of these unmounted drives, I open Disk Utility, select the drive and click the mount button. Works every time but involves several steps, so I decided to automate the process.
I have a working script that I think is making too many shell calls and I would like to simplify. In particular the first shell call could get the disk identifiers (for example "disk0s2") as well as the volume names. I tried building two lists from the first shell call, but couldn't figure out how to associate the second list after the "choose from list" part of the script.
The script that follows presents me with a list of attached hard drives from which I can choose a drive to mount, and mounts it after choosing. As I said, I think it could be simpler.
set theVolumeNamesList to {} set HFSdiskList to do shell script "diskutil list | grep Apple_HFS" set x to paragraphs of HFSdiskList repeat with LVar in items of x set thisVolumeName to word 3 of LVar set the end of theVolumeNamesList to thisVolumeName end repeat set volumeChoice to (choose from list theVolumeNamesList with prompt "Choose a volume to mount.") if the result is not false then set volumeToMount to volumeChoice set shellScpt to "diskutil list | grep " & volumeToMount & "" set whatItem to (do shell script shellScpt) --the disk identifier is the last word of what's returned here do shell script "diskutil mount " & (last word of whatItem) end if
Thanks J
|