在批处理文件中读取第二个参数,如果第一个参数有逗号 [英] Reading second argument in batch file if first argument has commas

查看:922
本文介绍了在批处理文件中读取第二个参数,如果第一个参数有逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sample.bat a,b,c,d yes

我想输出是通过回2%,但结果表明湾我觉得逗号也算作转义字符或什么的。我如何输出的是第二个参数?

I'm trying to output yes by echoing %2, but the result shows b. I think the comma is also counted as an escape character or something. How do I output yes as 2nd parameter?

推荐答案

您可以使用%* ,而不是与自己的规则解析它。

You could use %* instead and parse it with your own rules.

for /F "tokens=1,2 delims= " %%A in ("%*") DO (
  echo first=%%A
  echo second=%%B
)

这篇关于在批处理文件中读取第二个参数,如果第一个参数有逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆