Using info(“volumes”) I can check if a volume is mounted. Is there a way to mount a volume if it is not currently mounted?
LetLocal lvResult = “”
AppleScript |||
set theVol to “VolName”
do shell script “diskutil mountdiskutil list | awk '/ " & theVol & " / {print $NF}'
”
|||, lvResult
Similarly, you can use a shellscript to get the volume identifier and then either mount or unmount it. This script assumes the volume name is also in the VolName variable.
shellscript |||diskutil mount /dev/|||+arraylast(shellscript({diskutil list |grep "}+VolName+{"})," ")
If you want verification that it was executed you could use message ScriptResult which will return this with the name of your mounted volume:
Volume THEVOLUME on /dev/disk2s1 mounted
Both methods are using the diskutil command to get the job done.