add text string to a text file

October 16, 2010 at 23:50:29
Specs: Windows 2000
Hello,

I found the following code from IVO
------------------------------------------------------------------------------------------------------
:: NUM.BAT Usage: NUM File_IN > File_OUT
@echo off
for /F "tokens=1* delims=[]" %%a in ('find /V /N "" ^< %*') do (
echo.%%a:%%b
)
:: End_Of_batch

--------------------------------------------------------------------------------------------------------

How do I add a text string such as ### to the file, I like this text string as part of the batch command line.

ie NUM.bat ### File_IN > File_OUT

input file:
TEST
TEST
TEST

output

###1:TEST
###2:TEST
###3:TEST

Thank you
Bob


See More: add text string to a text file

Report •

#1
October 17, 2010 at 00:12:12
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=1* delims=[] " %%a in ('find /v /n "" ^< myfile') do (
>> newfile echo.%1%%a:%%b
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
October 17, 2010 at 00:53:39
Hello Mechanix2Go,

Thanks for you help.

Not sure how to use your solution. say
input file name = iii.txt
outputfile name = ooo.txt

I would like the command line to be like this:

NUM.bat ### iii.txt > ooo.txt


Report •

#3
October 17, 2010 at 02:09:52
As posted it's hardwired to myfile & newfile with one parameter: string.

If you want to name the files:

=======================================

@echo off & setLocal enableDELAYedeXpansion

if %3'==' echo you need 3 params: infile outfile string-to-prepend && goto :eof
> %2 type nul

for /f "tokens=1* delims=[] " %%a in ('find /v /n "" ^< %1') do (
>> %2 echo.%3%%a:%%b
)


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
October 17, 2010 at 11:04:09
Thanks Mechanix2Go.

Report •

#5
October 17, 2010 at 14:07:53
Thank You, Mechanix2Go.

Report •

Ask Question