Saturday, July 4, 2020

#1 2020-04-29 04:00:04 pm

MasterSwitch
Member
Registered: 2007-06-07
Posts: 1

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

Applescript:


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

Applescript:


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 big_smile

Offline

 

#2 2020-04-29 08:33:54 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 949

Re: diskutil list to get dev/disk#s#

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

Applescript:

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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)