Yep, but anyway "overcautious".nice
You see, for VOL use the way the batch loops, the "FIND" is only used to reduce the number of CALLs as, in *any* language the line that contains the serial is always the last one, and this (though looping more) would work as well:
@ECHO OFF SETLOCAL ENABLEEXTENSIONS IF %1.==. ECHO Missing drive letter&GOTO :EOF FOR /F "tokens=* delims=" %%? IN ('VOL %1') DO CALL :do_serial %%? ECHO Serial is: %Serial% GOTO :EOF :do_serial IF %2.==. SET Serial=%1&GOTO :EOF SHIFT GOTO :do_serial GOTO :EOFall in all it just ECHOes the last token of last line. (but it won't apply well to FORMAT output .
This would work as well (still for VOL use only):
@ECHO OFF SETLOCAL ENABLEEXTENSIONS IF %1.==. ECHO Missing drive letter&GOTO :EOF FOR /F "tokens=*" %%? IN ('VOL %1') DO SET Serial=%%? ECHO Serial is: %Serial:~-9%
Wonko