开发者

Escaping strings in a Windows Batch For Loop

I'm having problems with the following code:

FOR /f "tokens=*" %%A in (%MYFILE_PAT开发者_开发问答H%) do (
    [other stuff]
    echo %%A>> "%MYFILE_PATH%.scratch"
)

The file being read has XML in it and when < and > signs are read, the script throws errors. How can I escape the contents of %%A to safely echo to the output file? I don't want to put double quotes around it since it will then echo the quotes too.

Thanks


FOR /f "tokens=*" %%A in (%MYFILE_PATH%) do (
    [other stuff]
    (echo %%A)>>"%MYFILE_PATH%.scratch"
)

When appending the contents of %%A into another file, all that you are essentially doing is copying the file.

EDIT

 FOR /f "tokens=* delims=" %%A in (%MYFILE_PATH%) do (
    [other stuff]
    (echo %%A)>>"%MYFILE_PATH%.scratch"
)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜