开发者

Windows Batch File - Using Append with File Name that has spaces

I am creating a batch file to consolidat开发者_JAVA百科e some hard coded text with a few of other existing text files.

for this I am using the below.

set "txtFile=.\text.txt"
call:Append "C:\test 123\test.txt" %textFile%

over here, when I execute it, it thros an error as it is not able to proceed with the path as it has spaces.

how should this be addressed.


I have no idea what your append batch file is doing, but you can simply use copy to concatenate two files.

It's not clear to me what the needs to be appended to what, but the following will append the contents of text.txt to C:\test 123\test.txt by writing everything to C:\test 123\test.txt.

set txtFile=.\text.txt
copy "C:\test 123\test.txt" /a + %txtFile% /a "C:\test 123\test.txt"

If you want a different output file, just change the last parameter.

Btw: it's better to not rely on a specific working directory

The following:

set txtFile=%~dp0text.txt

makes sure that the text.txt is used that is in the same directory as your batch file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜