Le 28/04/2014 à 15:26, Nigel Garvey < email@hidden> a écrit : I wrote on Mon, 28 Apr 2014 09:55:39 +0100, I wrote:
Or the same can be achieved with:
set theVolumeNamesList to paragraphs of (do shell script "diskutil
list |
sed -En '/[^[:alpha:]]+Apple_HFS / {s///;s/[[:blank:]]{2}.+$//p;}'")
Yvan's pointed out to me off-list that the disk IDs are needed too. That's fairly easy to arrange:
set theVolumeNamesandIDsList to paragraphs of (do shell script "diskutil list | sed -En '/[^[:alpha:]]+Apple_HFS +/ {s///;s/[[:blank:]]+[0-9.]+[[:blank:]]+[A-Z]+[[:blank:]]+([[:alnum:]]+)$/\\'$'\\n''\\1/p;}'")
set theVolumeNamesList to {} set theIDsList to {} repeat with i from 1 to (count theVolumeNamesandIDsList) by 2 set end of theVolumeNamesList to item i of theVolumeNamesandIDsList set end of theIDsList to item (i + 1) of theVolumeNamesandIDsList end repeat
However, Shane's posted a solution which Yvan tells me doesn't truncate long names (an effect of "diskutil list" by itself), so that'll be better.
NG
Oops, I forgot to send the example of truncation in this area.
Using Diskutil I got : (*Macintosh HD, Samsung 32, archives AppleScript...*) (*disk0s2, disk1s2, disk2s2*)
Using Shane's code I got :
(*Macintosh HD, Samsung 32, archives AppleScript_Users*) (*disk0s2, disk1s2, disk2s2*)
As you may see, Diskutil is limited to 22 characters per volume name and when it truncates, it doesn't use the ellipsis character but three dots so that in fact only 19 characters are meaningful. If the goal is to allow the user to select a volume from Choose From List it seems that it may be annoying.
Yvan KOENIG (VALLAURIS, France) lundi 28 avril 2014 16:10:15
|