如何连接在Windows批处理文件中的字符串? [英] How to concatenate strings in a Windows batch file?
本文介绍了如何连接在Windows批处理文件中的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有,我想列出所有的 .DOC目录
文件以;
我知道下面的批处理命令回声所有文件:
为/ R %%我在格式(* .doc)DO呼应%%我
但现在我希望把他们都在一个变量中,添加;在一次
之间呼应他们全部结果
我该怎么做?
设置MYVAR =名单:
用于/ R %%我在格式(* .doc)DO<?&什么GT;
回声%MYVAR%
解决方案
什么:
关闭@echo
设置MYVAR =名单:
用于/ R %% i的格式(* .doc)DO拨打:CONCAT %%我
回声%MYVAR%
GOTO:EOF:CONCAT
设置MYVAR =%MYVAR%1%;
GOTO:EOF
I have a directory for which I want to list all the .doc
files with a ;
.
I know the following batch command echos all the files:
for /r %%i In (*.doc) DO echo %%i
But now I want to put them all in a variable, add a ;
in between and echo them all at once.
How can I do that?
set myvar="the list: "
for /r %%i In (*.doc) DO <what?>
echo %myvar%
解决方案
What about:
@echo off
set myvar="the list: "
for /r %%i in (*.doc) DO call :concat %%i
echo %myvar%
goto :eof
:concat
set myvar=%myvar% %1;
goto :eof
这篇关于如何连接在Windows批处理文件中的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文