开发者

Spaces in IN clause of BAT file for loop

I'm trying to run a command on all lines of a txt file through a batch file. I'm struggling to escape the characters in the IN () clause of the for loop.

This works:

for /F %%i IN (C:\test.txt) DO echo %%i

These don't:

for /F %%i IN (C:\Documents 开发者_如何学JAVAand Settings\user\Desktop\test.txt) DO echo %%i
for /F %%i IN ("C:\Documents and Settings\user\Desktop\test.txt") DO echo %%i
for /F %%i IN ('C:\Documents and Settings\user\Desktop\test.txt') DO echo %%i

Any idea how to get cmd to register that full path? Thanks-

Jonathan


Try the usebackq option of the for command.

for /F usebackq %%i IN ('C:\Documents and Settings\user\Desktop\test.txt') DO echo %%i
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜