开发者

Spaces in IN clause of BAT file for loop

开发者 https://www.devze.com 2023-01-06 06:54 出处:网络
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.

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

精彩评论

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

关注公众号