Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何处理包含空格作为单个参数的字符串?
SET STRING=this is my teststring call .\newFile.cmd %STRING% newFile.cmd: ECHO %1% //gives: "this"
试试看
SET STRING=this is my teststring call .\newFile.cmd "%STRING%" newFile.cmd: ECHO %~1
%~1删除周围的引号。
%~1
有两种方法:
1 - 在字符串周围使用引号
SET STRING="this is my teststring"
2 - 逃离空间
SET STRING=this\ is\ my\ teststring