batch-file - 连接批处理文件中的字符串

标签 batch-file

在下面的批处理文件中,我期望“C:\test Ground\”作为输出

set loc= C:\test Ground\

set withQuotes="%loc%"

但是我得到的是“C:\test Ground\”(注意引号开始后的额外前导空格)

如何解决这个问题?

最佳答案

只需去掉第一行 =C 之间的空格即可:

set loc=C:\test Ground\

如果这不是一个选项,您可以使用批处理的子字符串功能提取字符串的剩余部分(不含空格):

set withQuotes="%loc~1%"

关于batch-file - 连接批处理文件中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24213255/

相关文章:

windows - 如何用另一个 .exe 包装对 .exe(带参数)的调用?

windows - 我如何调用anotherfile.bat :label correctly in Batch?

windows - 如何以管理员身份从 Bamboo 运行批处理脚本?

windows - 暂停命令在 .bat 脚本中不起作用

windows - xcopy语法? (批)

encoding - 将 `dir`输出重定向到文件后,编码不正确

batch-file - 批处理文件消息框: Carriage return in message body

excel - 为什么命令提示符在两个位置之间切换?

c++ - 从 C++ 为 Batch 设置临时环境变量

java - 如何使用 J Connector 和其他 jar 文件为 Java 程序创建 bat 文件?