You are not logged in.
Please guys help me .
I need a batch that reads from txt file the contents and performs the operation e.g.
I have this txt ( subtract.txt) which contains the following
5-3
2-5
6-2
I need a new txt that will contain the reults of the above operations :
2
-3
4
... Please help me.
Offline
not tested:
@echo off
setlocal enableDelayedExpansion
break>result.txt
for /f "usebackq tokens=*" %%# in ("subtract.txt") do (
set /a result=%%#
echo !result!>>result.txt
)
Offline
npocmaka Thank u so much for your answer and for your time also. I tried it but all I get in result.txt is "ECHO is off". and when I try to execute it from cmd I get "Missing operand".
Offline
@echo off
setlocal enableDelayedExpansion
(for /f "usebackq tokens=*" %%# in ("subtract.txt") do (
set /a result=%%#
echo !result!
)) >result.txt
This way the process is more efficient...
Last edited by Aacini (02 Oct 2015 16:33)
Offline
It's my fault and I apologize. I gave you an example with small numbers. I actually want to operate numbers such :
105363-105200
78088-78056
153767-153318
129813-129813
149096-149096
129409-129408
136272-136272
95499-95467
135883-135787
120275-120949
I tried with small numbers the two codes from Aacini and npocmaka and both work (thank u so much). But with the numbers above it doesn't. Any suggesion ?
Offline
It works here!
C:\> test.bat
C:\> type result.txt
163
32
449
0
0
1
0
32
96
-674
Last edited by Aacini (02 Oct 2015 16:32)
Offline
I'll figure it out Aacini .... Maybe something I did wrong. Thank you for your precious time...
Offline
IT worked.... !!!!
There was something wrong with my pc.... !!! Thank you npocmaka , thank you Aacini !!! Thank you for your effort and for your time... !!!
Offline