You can use for /f
for that:
for /f %%L in ('dir /tw /-c b.bat ^| findstr /b "[0-9]"') do set CR=%%L
This assumes that there is only a single line of output, though. You cannot (trivially or usefully) capture more than one line in a variable.
I can only guess what you're really trying to do here, though. If you need the file size (just guessing because of the /-c
) then it's certainly easier to use
for %%X in (b.bat) do set size=%%~zX
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…