Search code examples
applescriptdisk

Applescript: list dev nodes of mounted and not mounted disks


Is it possible to get a list of dev nodes for disks using applescript? I found the system events application but cannot find the /dev entries there (like "/dev/disk1s1 on /"). I need something like 'mount' command but for the applescript.


Solution

  • System Events doesn't provide information about connected but unmounted disks.

    You need to use the shell. To get the dev node use

    set diskName to "MyVolume"
    set devNode to do shell script "diskutil list | awk '/ " & diskName & " / {print $NF}'"
    

    To mount a volume by name use

    set diskName to "MyVolume"
    do shell script "diskutil mount `diskutil list | awk '/ " & diskName & " / {print $NF}'`"