@echo off
"%~sdp0CDLabel.exe" "E:\linux\openSUSE\openSUSE-Leap-15.2-KDE-Live-x86_64-Media.iso"
for /f "tokens=4 delims=:" %%i in ('%~sdp0CDLabel.exe "E:\linux\openSUSE\openSUSE-Leap-15.2-KDE-Live-x86_64-Media.iso"') do if not defined CDlabel set "CDlabel=%%i"
echo CDlabel=%CDlabel% OK
pause
CD:ISO-9660 Size:963,837,952(919.19MB) Label:openSUSE_Leap_15.2_KDE_Live
CDlabel=openSUSE_Leap_15.2_KDE_Live OK
1、哦,原来输出之后,就是空格字符。我试了,批处理中直接替换也可以。
@echo off
"%~sdp0BOOTICE\CDLabel.exe" "E:\linux\openSUSE\openSUSE-Leap-15.2-KDE-Live-x86_64-Media.iso"
for /f "tokens=4 delims=:" %%i in ('%~sdp0BOOTICE\CDLabel.exe "E:\linux\openSUSE\openSUSE-Leap-15.2-KDE-Live-x86_64-Media.iso"') do if not defined CDlabel set "CDlabel=%%i" set "CDlabel=%CDlabel: =%"
echo CDlabel=%CDlabel%_OK
pause