diskutil list to get dev/disk#s#

hi

ive got a script for targeting HDDs internal and external, with and without partitions.

This works on external drives but not partitions


set diskDetails to (do shell script "diskutil list '" & myDiskName & "'")
set AppleScript's text item delimiters to space
set myDiskNumber to last item of (text items of diskDetails)

This works on partitions but not drives with certain syntax


set diskDetails to (do shell script "diskutil list | grep  '" & myDiskName & "'")
set AppleScript's text item delimiters to space
set myDiskNumber to last item of (text items of diskDetails)

it would be really good to have one line of code that works on internal and external, drives, with or without partitions & on drives with characters that can include but not limited to
-_~.

im looking for the
disk#s#
to target later on

can anyone help please ?

cheers
Clive :smiley:

Hi. I think this will work, but minimal testing was done.

set diskDetails to (do shell script "diskutil list | grep ' HD' | egrep -o 'disk\\w+' ")'s paragraphs