I have a code to print all string from multi files with below code:
for /f %%A in ('findstr /R "[0-9]" *.txt') do echo %%A
However the output concatenated when switching to different files:
C:\Users>echoarray.cmd
File1.txt:123
File1.txt:321
File1.txt:312File2.txt:456
File2.txt:654
File2.txt:546File3.txt:789
File3.txt:678
File3.txt:777File4.txt:123
File4.txt:789
File4.txt:999
What I want to do is, to put sum of all integer per row (from *.txt) into array then print output into one text file:
(Found this from here thanks to Gerhard)
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%a in ('findstr /R "[0-9]" *.txt') do (
set /a %%a+=1
set /a result[!%%a!]+=%%b
echo result[!%%a!] > result.txt
)
Example results would be like below (from output of echoarray.cmd above):
1491 ::my comment: first row result are from summation of 123+456+789+123
*continue for second row
*continue for third row
*continue for fourth row
I need your kind help to solve the concatenated output from findstr (hopefully someone can suggest me the correct solution for the array too).
P/S: I am using cmd on Windows 10