Úvod > Fórum > Software > Windows všeobecně > Return Disk Volume Label v CMD

Return Disk Volume Label v CMD

22.02.2021 20:17
příspěvků:1

Ahoj lidi.(W7Ux64) Potřebuji v CMD získat/dostat do proměnné Jméno Disku/Svazku. Např místo "E:" dostat "SG1T_A" atd.

Na

(https://stackoverflow.com/questions/8649934/how-to-read-the-label-of-a-drive-or-volume-in-a-batch-file)

jsem našel:
///

@echo off & setlocal enableextensions

set target_=D:
::
call :IsDeviceReady %target_% isready_
echo Device %target_% ready: %isready_%

if /i "%isready_%"=="false" (endlocal & goto :EOF)

::
call :GetLabel %target_% label_

echo The label of Volume %target_% is %label_%

endlocal & goto :EOF
::
:IsDeviceReady
setlocal
set ready_=true
dir "%~1" > nul 2>&1
if %errorlevel% NEQ 0 set ready_=false

endlocal & set "%2=%ready_%" & goto :EOF

::
:GetLabel
setlocal
for /f "tokens=5*" %%a in (

'vol "%~1"^|find "Volume in drive "') do (

set label_=%%b)

endlocal & set "%2=%label_%" & goto :EOF

///

Bohužel "label_" zůstává prázdný. Poradí mi někdo, v čem je chyba? Nebo jiný způsob?

© 2007-2024 PCforum.cz, všechna práva vyhrazena, veškeré informace zde uvedené jsou bez záruk, podmínky užití, kontaktní informace