FOR /F 未检索所有参数

FOR /F 未检索所有参数
@echo off
setlocal enableextensions
setlocal enabledelayedexpansion
set frase=Nome da impressora EPSON L110 Series
REM A linha abaixo ao inves de resultar em "EPSON L110 Series"
REM retorna apenas "EPSON"
REM The line below should return "EPSON L110 Series"
REM instead of only "EPSON"
for /f "tokens=4" %%G IN ("%frase%") DO echo %%G

我该如何纠正它以返回“打印机名称”后的所有字符串?

答案1

用 替换该forfor /f "tokens=4*" %%G IN ("%frase%") DO echo %%G %%H应该会打印该行的剩余部分。请参阅For /f - 循环遍历文本 | Windows CMD | SS64.com. 从该页面:

tokens=3* 将处理第三个标记和第四个标记 + 所有后续项目,也可以写成 tokens=3,*
...

%%G 在 FOR 语句中声明,而 %%H 通过 tokens= 选项隐式声明。

相关内容