editing var in txt with bat

February 16, 2010 at 14:11:59
Specs: Windows XP
I have a txt file that I want to change certian numbers in. I would like cmd to ask me what to change them to with a .bat file.
EX.
1
2
3
4
1+4=5 ( i want to change the five with cmd)

thanks


See More: editing var in txt with bat

Report •

#1
February 16, 2010 at 17:30:09
something like:
setlocal enabledelayedexpansion
set /p xx=change value (5) to:
for /f "tokens=*" %%a in (text) do (
set zz=%%a
set zz=!zz:5=%xx%!
>> new echo !zz!
)

Report •

#2
February 17, 2010 at 04:31:02
This is what i ran. It created a new text file and put the variable in it. I would like to edit the existing text file 2.txt and change the 5's to what ever cmd asks


setlocal enabledelayedexpansion
set /p xx=change value (5) to:
for /f "tokens=*" %%a in (2.txt) do (
set zz=%%a
set zz=!zz:5=%xx%!
>> new echo !zz!
)


Report •

#3
February 17, 2010 at 07:24:48
add the foll. as the last line of the script:
move /y new 2.txt

Report •

Related Solutions

#4
February 17, 2010 at 08:08:06
sorry I am new to this.

Ultimatly I want to copy 2.txt and change certain vars for example 5 to 6 in the new copy


Report •

Ask Question