user3004625
user3004625

Reputation: 31

Copy only integer from a text file via batch script

I have two text file : aa.txt and bb.txt Content of aa.txt is :

======= TOTAL AMOUNT 5937456 =========
======= TOTAL AMOUNT 5564789 =========

Content of bb.txt is :

======= TOTAL AMOUNT 857439898 =========
======= TOTAL AMOUNT 556443789 =========

Now I want to copy only integer part eg : 5937456,857439898 etc from the above text files to excel sheet. Can anyone help me?? Thanks

Upvotes: 1

Views: 191

Answers (1)

npocmaka
npocmaka

Reputation: 57252

Not tested:

for /f "tokens=3 delims== " %%a in ('type aa.txt^|find /i "TOTAL AMOUNT"') do (
   echo %%a
   set /a the_number=%%a

)

For the copying to excel you'll need jscript/vbscript/powershell. Or you can output the number s in CSV and open it with excel.

Upvotes: 1

Related Questions