w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
diskpart select by disk label

As there is missing valid drive letter in some lines of the Diskpart output (list volume, column ltr), then tokens in line #19

For /F "Tokens=1,2,3*" %%I In ('Diskpart /S "%_OFile1%"^|Findstr
/I /R /C:"Disk [0-9]" /C:"Volume [0-9]"') Do (

display as follows (and we have our culprit now):

%%I    %%J  %%K      %%L
Volume 0    D        USBBOOT      UDF    DVD-ROM      329 MB ...
Volume 1    Windows  NTFS   Partition     40 GB  Healthy
Volume 2    Recovery NTFS   Partition     19 GB  Healthy
Volume 3    Z        WINPE        FAT32  Removable   7632 MB ...

Therefore you could use next snippet code (instead of lines 19..26) in your script:

For /F "Tokens=1*" %%I In ('Diskpart /S "%_OFile1%"^|Findstr /I
/R /C:"Disk [0-9]" /C:"Volume [0-9]"') Do (
  If /I %%I==Disk (
    Set _Tmp=%%J:
) Else (
    Set _Label=%%J
    Set _Label=!_Label:~10,11!
>>"%_OFile2%" Echo.!_Tmp!%%J:!_Label!
))

Care this change interferes _Tmp variable!





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.