| 1. |
Solve : echo %%i throu FOR loop? |
|
Answer» Dear friends, in batch i write for /f "delims=" %%i in ('find "ABC" ^<MyFile.TXT') do echo.%%i>> NewFile.TXT Or this: Quote find "ABC" <MyFile.TXT >>NewFile.TXTThank you very very much, i use the 1st suggetion because i need more manipulations. Please tell me what is this use/behaviour of ^ before the input < after your solution i tried instead of the use of ^ this: '"find "ABC" OK i realized that it's an escape char that causes to interpret codes as simple chars. I see that robvanderwoude has a lot about it. again thank you very muchQuote from: yossi_moses on JULY 25, 2012, 08:38:35 AM after your solution i tried instead of the use of ^ this: '"find "ABC" <MyFile.TXT"' and it also worked. If you try that again in a for in do loop command you will find that it generates an error and will fail. I'm glad you found the solution useful. Am I missing something? Code: [Select]C:\>type myfile.txt abc&def abc<def abc|def abc>def 123>asd\678 123<asd\678 123&asd\678 123|asd\678 C:\>type test1.bat @echo off for /f "delims=" %%i in (myfile.txt) do echo.%%i>>newfile.txt C:\>test1.bat C:\>type newfile.txt abc&def abc<def abc|def abc>def 123>asd\678 123<asd\678 123&asd\678 123|asd\678 C:\> A later post revealed that this was more like the real request: for /f "delims=" %%i in (MyFile.TXT) do echo.%%i|find "ABC" >> NewFile.TXTDear Salmon Trout, 1st, thanks a lot. But it seems that indeed some thing is missed. very strange, but ECHO%%Var>FileName is well escaped (no need for escape chars), and ECHO%%Var|FIND is not escaped. Please HELP me to UNDERSTAND how to thank in a way that my thank to any body will be counted in the forum. Thanks |
|