Saved Bookmarks
| 1. |
Solve : Batch file needed to wrap entire text column in double quotes? |
|
Answer» Just JOINED here to ask this ! I have a TEXT file that has multiple lines without any QUOTES. I NEED a batch file that will append a single double QUOTE at the beginning of the first line (not on a separate line by itself , it must be the first character on the first line) I need the same for the very last line position also. So to end up looking like "One Two Three Four Five Six Seven" ...Therefore wrapping the entire column. I hope you guys can solve this for me as its been driving me nuts ! Thanks in advance !It is customary to post whatever code you have created so we can better see where you're going with this. In any case, my batch codes days are pretty much behind me, but I did come up with this: Code: [Select]echo off setlocal enabledelayedexpansion set count=0 set ifile=g:\wfc\testlib\hope.txt set ofile=c:\temp\hopeless.txt for /f %%b in ('type !ifile! ^| find "" /v /c') do set ubound=%%b for /f %%i in (!ifile!) do ( set /a count=!count!+1 if !count! EQU 1 ( echo ^"%%i >> !ofile! ) else if !count! EQU !ubound! ( echo %%i^" >> !ofile! ) else ( echo %%i >> !ofile! ) ) Change the ifile and ofile values in the set statements to match your environment. Happy Coding |
|